diff options
author | merakor <cem@ckyln.com> | 2021-04-25 09:17:38 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2021-04-25 09:17:38 +0000 |
commit | fb98eac3bb4060100c174247446d72dafc075112 (patch) | |
tree | b5b9187d98f13599dd0e7910581f3e38b45e0428 | |
parent | e432b31ef398ef7a73cbe002c536dba7dec62b84 (diff) | |
download | cpt-fb98eac3bb4060100c174247446d72dafc075112.tar.gz |
pkg_repository_info: cache repository information for later use
FossilOrigin-Name: c0bbaed4949169d212ece054db5c9f278abb57f1242043bcb18409a286e3cb45
-rw-r--r-- | src/cpt-lib.in | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/cpt-lib.in b/src/cpt-lib.in index 64f2869..55553e4 100644 --- a/src/cpt-lib.in +++ b/src/cpt-lib.in @@ -1648,14 +1648,18 @@ pkg_repository_info() { # will return current directory, repository root, and the type of repository # in a colon separated format. - if rootdir=$(git rev-parse --show-toplevel 2>/dev/null); then + : "${repo_file:=$cac_dir/repository-cache}" + + if information=$(grep "^$PWD:" "$repo_file" 2>/dev/null); then + # Repository information is already cached. + printf '%s\n' "$information" | sed 1q + return + elif rootdir=$(git rev-parse --show-toplevel 2>/dev/null); then # Git repository backend=git - elif rootdir=$(hg root 2>/dev/null); then # Mercurial repository backend=hg - elif rootdir=$(fossil info 2>/dev/null | grep ^local-root:); then # Fossil repository backend=fossil @@ -1665,7 +1669,6 @@ pkg_repository_info() { $rootdir EOF rootdir=${rootdir%/} - elif [ -f .rsync ]; then backend=rsync rootdir=$PWD @@ -1683,7 +1686,7 @@ EOF backend=local rootdir=$PWD fi - printf '%s:%s:%s\n' "$PWD" "$rootdir" "$backend" + printf '%s:%s:%s\n' "$PWD" "$rootdir" "$backend" | tee -a "$repo_file" } pkg_fetch() { |