Skip to content

Commit

Permalink
setup empty allowed signers to check ssh signature status
Browse files Browse the repository at this point in the history
  • Loading branch information
gavin-ts committed Oct 12, 2023
1 parent 782b3f6 commit c838bcc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.changed-files
.emptyAllowedSigners
14 changes: 13 additions & 1 deletion lib/git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ ensure_signed() {
return
fi

# look for signature status N: no signature
setup_allowed_signers
# look for signature status N: no signature (verification done by github)
if [ ! "$(git log --format="%G?" ${GIT_BASE:+"$GIT_BASE..HEAD"} | grep "N")" ]; then
return
fi
Expand All @@ -186,6 +187,17 @@ ensure_signed() {
return 1
}

setup_allowed_signers() {
# we only care if a signature is present (github will verify) so we don't need any entries,
# but "gpg.ssh.allowedSignersFile needs to be configured and exist for ssh signature verification"
if git config --get gpg.ssh.allowedSignersFile >/dev/null; then
return
fi
allowed_signers=".emptyAllowedSigners"
touch $allowed_signers
git config --local gpg.ssh.allowedSignersFile "$allowed_signers"
}

git_commit_count() {
# macOS sh is buggy and requires the subshell here.
(git rev-list HEAD --count 2>/dev/null) || echo 0
Expand Down

0 comments on commit c838bcc

Please sign in to comment.