From fb98eac3bb4060100c174247446d72dafc075112 Mon Sep 17 00:00:00 2001 From: merakor Date: Sun, 25 Apr 2021 09:17:38 +0000 Subject: pkg_repository_info: cache repository information for later use FossilOrigin-Name: c0bbaed4949169d212ece054db5c9f278abb57f1242043bcb18409a286e3cb45 --- src/cpt-lib.in | 13 ++++++++----- 1 file 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() { -- cgit v1.2.3