From e1bb0e2cb68265458d4540ae566c255263d918a2 Mon Sep 17 00:00:00 2001 From: Billy Lynch Date: Thu, 11 Jan 2024 14:42:52 -0500 Subject: git: worktree_commit, Add crypto.Signer option to CommitOptions. This change adds a new crypto.Signer option to CommitOptions as an alternative to SignKey to allow alternative commit signers to be used. This change byitself does not add other signing methods (e.g. ssh, x509, gitsign), but gives callers the ability to add their own. This roughly follows git's sign_buffer approach where go-git handles the commit message body encoding, and hands off the encoded []byte to the signing implementation for the signature to be returned. Signed-off-by: Billy Lynch --- options.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'options.go') diff --git a/options.go b/options.go index e748b91..ddd637b 100644 --- a/options.go +++ b/options.go @@ -1,6 +1,7 @@ package git import ( + "crypto" "errors" "fmt" "regexp" @@ -507,6 +508,10 @@ type CommitOptions struct { // commit will not be signed. The private key must be present and already // decrypted. SignKey *openpgp.Entity + // Signer denotes a cryptographic signer to sign the commit with. + // A nil value here means the commit will not be signed. + // Takes precedence over SignKey. + Signer crypto.Signer // Amend will create a new commit object and replace the commit that HEAD currently // points to. Cannot be used with All nor Parents. Amend bool -- cgit