Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix checking commit signature when signed with ssh key #29

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.sh
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,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 @@ -344,6 +345,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
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