Created
December 14, 2023 07:07
-
-
Save ichizok/5f78a8bfe5bb4b7306ec06a1ef729910 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eo pipefail | |
# | |
# Git invokes the following command with commit-data for code-signing. | |
# | |
# gpg --status-fd 2 -bsau {signing_key} | |
# | |
while getopts :u:-: OPT; do | |
# Skip long options. | |
[[ ${OPT} = - ]] \ | |
&& ! [[ ${OPTARG} =~ = ]] \ | |
&& ! [[ ${!OPTIND} =~ ^- ]] \ | |
&& shift | |
[[ ${OPT} = u ]] && SIGNING_KEY=${OPTARG} | |
done | |
if [[ -z "${SIGNING_KEY}" ]]; then | |
# Probably to verify a signed commit. | |
exec gpg "$@" | |
exit 127 | |
fi | |
exec 3<<<"$(pass show "gpg/${SIGNING_KEY%!}")" | |
exec gpg --batch --pinentry-mode loopback --passphrase-fd 3 "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment