Skip to content

Commit

Permalink
Add commit signing verification to Git pre-commit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
psirenny authored Aug 31, 2024
1 parent 3945c9d commit 712133a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 0 additions & 3 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit ${1}
8 changes: 8 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
if git config --get commit.gpgsign | grep -q "true"; then
# It’s still possible signing was disabled for this particular commit with `git commit --no-gpg-sign`.
# But we ignore that case because it’s difficult to detect.
exit 0;
fi

echo "Commit signing is required. See: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits"
exit 1;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"github-actions:push": "act push -s GH_PAT=$GH_PAT -s GITHUB_TOKEN=$GH_PAT -s NPM_TOKEN=$NPM_TOKEN",
"github-actions:push:release-tag": "act push -e .github/test-events/push-release-tag.json -s GH_PAT=$GH_PAT -s GITHUB_TOKEN=$GH_PAT",
"npmpkgjsonlint:check": "npmPkgJsonLint .",
"prepare": "husky",
"prettier:check": "prettier --check .",
"prettier:fix": "prettier --write .",
"publish-packages": "yarn run publish-packages:npm && yarn run publish-packages:github && yarn run publish-packages:custom && yarn changeset tag",
Expand Down

0 comments on commit 712133a

Please sign in to comment.