From e3ac4e50643e406a569caa75d56c8d6af1a523e5 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 21 May 2024 08:00:00 +0100 Subject: [PATCH] Store multiple results Create a hash of the repo path and store it as its own result, allowing for a different cached result per repo path. --- git-commit-length-counter.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/git-commit-length-counter.sh b/git-commit-length-counter.sh index 5af6b86..dcf184b 100755 --- a/git-commit-length-counter.sh +++ b/git-commit-length-counter.sh @@ -12,7 +12,13 @@ REPO="${REPO:-$(pwd)}" # Return early if the repository directory doesn't exist. [[ ! -d "${REPO}" ]] && exit 2 -result_file="./result" +mkdir -p ./result + +repo_hash="$(echo -n "${REPO}" | md5sum | cut -d ' ' -f1)" +result_file="./result/${repo_hash}" + +echo "Result file: ${result_file}" + if [[ ! -f "${result_file}" ]]; then for commit_id in $(git -C "${REPO}" rev-list --all --no-merges); do echo "Processing commit ${commit_id}..."