gpt4 book ai didi

git - 我可以使用 keybase.io 签署 git 提交吗?

转载 作者:行者123 更新时间:2023-12-03 03:29:47 26 4
gpt4 key购买 nike

我正在设置一台新机器,并且更愿意使用 keystore 进行各种 pgp 事件,例如签名提交。我可以运行这样的命令

$ keybase pgp sign -m foo > x
$ gpg --verify x 2>&1 | grep -oF 'Good signature'
Good signature

我可以直接使用 gpg 进行签名,但让 keybase 管理该东西会很方便。那么我可以以某种方式让 git 使用 keybase 吗?

Git configuration似乎没有办法自定义用于签署提交的 gpg 命令。您所能做的就是提供 key 。有什么办法可以做到吗?

最佳答案

感谢 Xavier's answer 中的链接我了解到我可以使用 gpg.program 配置覆盖 gpg 程序:

git config --global gpg.program /path/to/something

所以我可以用它来编写一个围绕键库的包装器。

但事实证明,git 对于某物 是什么非常挑剔。 Git expects to partially parse--fd-status 标志产生的输出,这会导致 gpg 输出 special status codes在备用文件句柄处。

幸运的是,至少在我的第一遍中,git 不会解析 gpg 生成的所有内容,因此我能够模拟它。 Here's a gist with a functional wrapper ,这就是它的核心内容:

# Copy the commit message from stdin to a file. 
d=$(mktmp -d "${TMPDIR:-/tmp}/gitsig.XXXXXXXXX")
cat > "$d/commit.msg"

# Have Keybase write the signature to another file.
keybase pgp sign --detached \
--key "$1" \
--infile "$d/commit.msg" \
--outfile "$d/commit.sig"

# Have gpg verify the signature right away.
# Capture its status in a file.
gpg --verify --status-fd=2 \
"$d/commit.sig" "$d/commit.msg" \
> /dev/null 2> "$d/gpgstatus.txt"

# Copy the KEY_CONSIDERED lines to stderr. Git wants that.
grep '^\[GNUPG:\] KEY_CONSIDERED' "$d/gpgstatus.txt" >&2

# Produce a minimal SIG_CREATED line to stderr. Git also wants that.
printf '[GNUPG:] SIG_CREATED ' >&2

关于git - 我可以使用 keybase.io 签署 git 提交吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58442313/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com