From 2976a241af2bdd872e85581b4f27cfeb1f4c343e Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Tue, 18 Mar 2025 13:47:27 +0545 Subject: [PATCH] only validate each commit once --- hooks/validate.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hooks/validate.sh b/hooks/validate.sh index 486a7df..94ba350 100755 --- a/hooks/validate.sh +++ b/hooks/validate.sh @@ -42,6 +42,7 @@ if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi . "$DIR/timestamping" declare -i MINVERSION=$TIMESTAMPING_VERSION +declare -A PROCESSED_COMMIT while [[ $# -gt 0 ]]; do KEY="$1" @@ -89,6 +90,10 @@ fi # tokens, the function will return 0 but echo a warning about the invalid token. validate_commit() { local COMMIT_HASH="$1" + if [[ ${PROCESSED_COMMIT[$COMMIT_HASH]} ]]; then + log "validate_commit for $COMMIT_HASH has already been validated" + return 0 + fi log "validate_commit for $COMMIT_HASH" local TIMESTAMP_COMMIT_VERSION @@ -275,6 +280,8 @@ validate_commit() { #assert that all extracted timestamps have been processed assert "[ $NUM_PROCESSED -eq $NUM_EXTRACTED ]" "All extracted token must be processed." + PROCESSED_COMMIT[$COMMIT_HASH]=1 + if [ $NUM_VALID -gt 0 ]; then if [ $NUM_INVALID -gt 0 ]; then echo_warning "Warning: While commit $COMMIT_HASH contains $NUM_VALID valid timestamp tokens and thus is considered proppely timestamped, it also contains $NUM_INVALID invalid timestamp tokens."