feature: limit the number of commits to be validated
All checks were successful
Validate Trusted Timestamps Actions Demo / Validate (push) Successful in 49s
All checks were successful
Validate Trusted Timestamps Actions Demo / Validate (push) Successful in 49s
Signed-off-by: Phil Davis <phil@jankaritech.com>
This commit is contained in:
@@ -42,6 +42,7 @@ if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
|
|||||||
. "$DIR/timestamping"
|
. "$DIR/timestamping"
|
||||||
|
|
||||||
declare -i MINVERSION=$TIMESTAMPING_VERSION
|
declare -i MINVERSION=$TIMESTAMPING_VERSION
|
||||||
|
declare -i MAX_COMMITS_TO_CHECK=20
|
||||||
declare -A PROCESSED_COMMIT
|
declare -A PROCESSED_COMMIT
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
@@ -62,6 +63,16 @@ while [[ $# -gt 0 ]]; do
|
|||||||
shift # past argument
|
shift # past argument
|
||||||
shift # past value
|
shift # past value
|
||||||
;;
|
;;
|
||||||
|
-max|--maxcommits)
|
||||||
|
INTEGER_REGEX='^[0-9]+$'
|
||||||
|
if ! [[ "$2" =~ $INTEGER_REGEX ]]; then
|
||||||
|
echo_error "$KEY: expected positive integer"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
MAX_COMMITS_TO_CHECK="$2"
|
||||||
|
shift # past argument
|
||||||
|
shift # past value
|
||||||
|
;;
|
||||||
-v|--verbose)
|
-v|--verbose)
|
||||||
OUT_STREAM=/dev/stdout
|
OUT_STREAM=/dev/stdout
|
||||||
shift # past argument
|
shift # past argument
|
||||||
@@ -307,6 +318,8 @@ validate_commit_and_parents() {
|
|||||||
if ! validate_commit "$COMMIT_HASH"; then
|
if ! validate_commit "$COMMIT_HASH"; then
|
||||||
ALL_PASSED=false
|
ALL_PASSED=false
|
||||||
fi
|
fi
|
||||||
|
NUM_COMMITS_CHECKED=${#PROCESSED_COMMIT[@]}
|
||||||
|
if [[ ${NUM_COMMITS_CHECKED} -lt ${MAX_COMMITS_TO_CHECK} ]] ; then
|
||||||
local PARENTS=$(git cat-file -p "$COMMIT_HASH" | awk '/^$/{exit} /parent/ {print}' | sed 's/parent //')
|
local PARENTS=$(git cat-file -p "$COMMIT_HASH" | awk '/^$/{exit} /parent/ {print}' | sed 's/parent //')
|
||||||
#iterate over all parents of commit
|
#iterate over all parents of commit
|
||||||
if [ ! -z "$PARENTS" ]; then
|
if [ ! -z "$PARENTS" ]; then
|
||||||
@@ -316,6 +329,7 @@ validate_commit_and_parents() {
|
|||||||
fi
|
fi
|
||||||
done <<< $(printf "%s" "$PARENTS")
|
done <<< $(printf "%s" "$PARENTS")
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if [ "$ALL_PASSED" = true ]; then
|
if [ "$ALL_PASSED" = true ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user