mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-20 17:11:17 +00:00
1.5 KiB
1.5 KiB
name, description
| name | description |
|---|---|
| gpg-commit-signing | Sign git commits with GPG in non-interactive environments. Use when committing code and the `GPG_PRIVATE_KEY_PASSPHRASE` environment variable is available. Triggers on "commit", "sign commit", "GPG", "git commit -S", or any git operation requiring signed commits. |
GPG Commit Signing
Sign commits in headless/non-interactive environments where /dev/tty is unavailable.
Workflow
-
Check whether
GPG_PRIVATE_KEY_PASSPHRASEis set:test -n "$GPG_PRIVATE_KEY_PASSPHRASE" && echo "available" || echo "not set"If not set, skip signing — commit without
-S. -
Try a direct signed commit first — the environment may already have loopback pinentry configured:
git commit -S -m "message"If this succeeds, no further steps are needed.
-
If step 2 fails with a
/dev/ttyerror, use--pinentry-mode loopbackvia a wrapper script:printf '#!/bin/sh\ngpg --batch --pinentry-mode loopback --passphrase "$GPG_PRIVATE_KEY_PASSPHRASE" "$@"\n' > /tmp/gpg-sign.sh chmod +x /tmp/gpg-sign.sh git -c gpg.program=/tmp/gpg-sign.sh commit -S -m "message" rm /tmp/gpg-sign.shThis passes the passphrase directly to gpg on each signing invocation, bypassing the need for a configured gpg-agent.
Anti-patterns
- Do not echo or log
GPG_PRIVATE_KEY_PASSPHRASE. - Do not commit without
-Swhen the passphrase is available — the project expects signed commits. - Do not leave wrapper scripts on disk after committing.