fix recent git test cases

This commit is contained in:
Lance Vick 2020-12-07 21:23:40 -08:00
parent 88e8bed6ca
commit ed0b58c05f
Signed by: lrvick
GPG Key ID: 8E47A1EC35A1551D
1 changed files with 13 additions and 4 deletions

15
sig
View File

@ -273,12 +273,13 @@ verify_git(){
[ $# -eq 2 ] || die "Usage: verify_git <threshold> <group>" [ $# -eq 2 ] || die "Usage: verify_git <threshold> <group>"
local -r threshold="${1}" local -r threshold="${1}"
local -r group="${2}" local -r group="${2}"
local seen_fps="" sig_count=0 ref commit fp uid local seen_fps="" sig_count=0 ref commit git_fp fp uid
git verify-commit HEAD >/dev/null 2>&1 \ git verify-commit HEAD >/dev/null 2>&1 \
|| die "HEAD commit not signed" || die "HEAD commit not signed"
fp=$(git log --format="%GP" HEAD -n1 ) git_fp=$(git log --format="%GP" HEAD -n1 )
fp=$(get_primary_fp "$git_fp")
seen_fps="${fp}" seen_fps="${fp}"
sig_count=1 sig_count=1
uid=$( get_uid "${fp}" ) uid=$( get_uid "${fp}" )
@ -286,11 +287,12 @@ verify_git(){
for tag in $(git tag --points-at HEAD); do for tag in $(git tag --points-at HEAD); do
git tag --verify "$tag" >/dev/null 2>&1 && { git tag --verify "$tag" >/dev/null 2>&1 && {
fp=$( \ git_fp=$( \
git verify-tag --raw "$tag" 2>&1 \ git verify-tag --raw "$tag" 2>&1 \
| grep VALIDSIG \ | grep VALIDSIG \
| sed 's/.*VALIDSIG \([A-Z0-9]\+\).*/\1/g' \ | sed 's/.*VALIDSIG \([A-Z0-9]\+\).*/\1/g' \
) )
fp=$(get_primary_fp "$git_fp")
uid=$( get_uid "${fp}" ) uid=$( get_uid "${fp}" )
if [[ "${seen_fps}" != *"${fp}"* ]]; then if [[ "${seen_fps}" != *"${fp}"* ]]; then
seen_fps="${seen_fps} ${fp}" seen_fps="${seen_fps} ${fp}"
@ -313,6 +315,11 @@ verify_git(){
} }
done done
fi fi
if [[ $(git diff --stat) != '' ]]; then
die "Error: git tree is dirty"
fi
} }
## Get temporary dir reliably across different mktemp implementations ## Get temporary dir reliably across different mktemp implementations
@ -360,6 +367,8 @@ verify(){
if [ "$method" == "git" ]; then if [ "$method" == "git" ]; then
command -v git >/dev/null 2>&1 \ command -v git >/dev/null 2>&1 \
|| die "Error: method 'git' specified and git is not installed" || die "Error: method 'git' specified and git is not installed"
[ -d .git ] \
|| die "Error: This folder is not a git repository"
fi fi
if command -v git >/dev/null 2>&1 \ if command -v git >/dev/null 2>&1 \
&& ( [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1 ); && ( [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1 );