From 0e523bd1eebd78ea32cbea9039430e524b03fdc7 Mon Sep 17 00:00:00 2001 From: Artur Neumann Date: Mon, 23 Dec 2024 15:37:29 +0545 Subject: [PATCH] fix running validate with -v running ./.git/hooks/validate.sh -v gives me Assertion failed: Precondition: hash -v must have length 64. Backtrace: [1]: ./.git/hooks/timestamping : extract_token_from_commit line 200 [2]: ./.git/hooks/validate.sh : validate_commit line 97 [3]: ./.git/hooks/validate.sh : validate_commit_and_parents line 300 [4]: ./.git/hooks/validate.sh : main line 329 this commit fixes the issue --- hooks/validate.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hooks/validate.sh b/hooks/validate.sh index 1c52822..9089853 100644 --- a/hooks/validate.sh +++ b/hooks/validate.sh @@ -43,7 +43,7 @@ if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi declare -i MINVERSION=$TIMESTAMPING_VERSION -while [[ $# -gt 1 ]]; do +while [[ $# -gt 0 ]]; do KEY="$1" case $KEY in @@ -66,12 +66,12 @@ while [[ $# -gt 1 ]]; do shift # past argument ;; *) # unknown option - echo_error "Unknown argument: $KEY" - exit 1 + OBJECT=$KEY + shift # past argument ;; esac done -OBJECT="$1" + if [ -z "$OBJECT" ]; then OBJECT="HEAD" fi @@ -332,4 +332,4 @@ if validate_commit_and_parents "$COMMIT_HASH"; then else echo_error "Validation Failed: There are timestamped commits in the commit history of $COMMIT_HASH which do not contain any valid timestamps." exit 1 -fi \ No newline at end of file +fi