This repository was archived by the owner on Sep 11, 2020. It is now read-only.
This repository was archived by the owner on Sep 11, 2020. It is now read-only.
Utility func for creating a commitSignKey #1012
Open
Description
I feel like it's worth creating a utility func to enable users to easily create a commitSignKey from armoredKeyRing, key identity and passphrase strings (if applicable).
Something akin to what's in https://github.com/src-d/go-git/blob/master/worktree_commit_test.go (obviously minus all the test assertions):
func commitSignKey(c *C, decrypt bool) *openpgp.Entity {
s := strings.NewReader(armoredKeyRing)
es, err := openpgp.ReadArmoredKeyRing(s)
c.Assert(err, IsNil)
c.Assert(es, HasLen, 1)
c.Assert(es[0].Identities, HasLen, 1)
_, ok := es[0].Identities["foo bar <[email protected]>"]
c.Assert(ok, Equals, true)
key := es[0]
if decrypt {
err = key.PrivateKey.Decrypt([]byte(keyPassphrase))
c.Assert(err, IsNil)
}
return key
}
I had a look into the code, and Issues, and couldn't find anything related.
What're people's thoughts on this.. Is it worth it? Any downsides? Or have I missed something?