Skip to content

Commit ac68d2a

Browse files
ci(workflow): ⚡ update commit signing
1 parent 573a6e2 commit ac68d2a

File tree

3 files changed

+33
-10
lines changed

3 files changed

+33
-10
lines changed

.husky/scripts/check-commit.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
COMMIT_MSG_FILE="${1:-}"
5-
COMMIT_MSG=$(cat $COMMIT_MSG_FILE)
4+
COMMIT_MSG_FILE="$1"
5+
COMMIT_MSG=$(cat "$COMMIT_MSG_FILE")
6+
TYPES="feat|fix|chore|docs|test|style|refactor|perf|build|ci|revert"
7+
SCOPE="\(.+\)"
68

79
_validate_commit_message() {
810
if [ ! -f "$COMMIT_MSG_FILE" ]; then
@@ -20,9 +22,6 @@ check_commit_convention() {
2022
local commit_msg_file="$1"
2123
_validate_commit_message "$commit_msg_file"
2224

23-
TYPES="feat|fix|chore|docs|test|style|refactor|perf|build|ci|revert"
24-
SCOPE="\(.+\)"
25-
2625
echo "Commit message: $COMMIT_MSG"
2726

2827
if ! echo "$COMMIT_MSG" | grep -qE "^($TYPES)($SCOPE)?:"; then
@@ -31,4 +30,7 @@ check_commit_convention() {
3130
echo -e "Format should be: <type>(optional scope): <description> \n"
3231
exit 1
3332
fi
34-
}
33+
}
34+
35+
# Main execution
36+
check_commit_convention "$COMMIT_MSG_FILE"

.husky/scripts/check-coverage.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# Exit on error, unset vars, and pipeline failures
2+
# Exit on error, unset vars, and pipeline failures, like strict mode in JS
33
set -euo pipefail
44

55
MIN_COVERAGE=70

.husky/scripts/dont-trust.sh

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,35 @@ set -euo pipefail
99
dont_trust() {
1010
echo "🔏 Verifying commit signature..."
1111

12+
# Check GPG signature configuration
13+
if ! git config --get user.signingkey >/dev/null; then
14+
echo "❌ No GPG signing key configured"
15+
16+
echo "Run: git config --global user.signingkey YOUR_KEY_ID"
17+
echo "1. Generate a key: gpg --full-generate-key"
18+
echo "2. List keys: gpg --list-secret-keys --keyid-format LONG"
19+
echo "3. Configure Git: git config --global user.signingkey YOUR_KEY_ID"
20+
exit 1
21+
fi
22+
23+
# Check if commit signing is enabled
24+
if [ "$(git config --get commit.gpgsign)" != "true" ]; then
25+
echo "❌ Error: Commit signing not enabled"
26+
echo "Run: git config --global commit.gpgsign true"
27+
exit 1
28+
fi
29+
30+
# https://git-scm.com/docs/git-log#Documentation/git-log.txt-emGem
31+
# Get detailed signing information
1232
VERIFY_SIGNING=$(git log -1 --pretty=%G?)
1333

14-
if [[ "$VERIFY_SIGNING" != 'G' && "$VERIFY_SIGNING" != 'E' ]]; then
34+
if [[ "$VERIFY_SIGNING" != 'G']]; then
1535
echo "❌ Error: Commit is not signed"
16-
echo "Please sign your commit."
36+
echo "Please sign your commit with a valid GPG key."
37+
echo "Run: git config --global commit.gpgsign true"
1738
exit 1
1839
fi
1940

2041
echo "🔑 Commit signed!"
21-
42+
echo "✅ Valid signature from: ${SIGNER_INFO}
2243
}

0 commit comments

Comments
 (0)