Merge pull request 'only validate each commit once' (#7) from validate-each-commit-once-only into main
All checks were successful
Validate Trusted Timestamps Actions Demo / Validate (push) Successful in 2m59s

Reviewed-on: #7
Reviewed-by: Artur Neumann <artur@jankaritech.eu>
This commit is contained in:
2025-03-19 03:55:52 +00:00

View File

@@ -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."