aboutsummaryrefslogtreecommitdiffstats
path: root/options.go
diff options
context:
space:
mode:
authorBilly Lynch <billy@chainguard.dev>2024-01-11 14:42:52 -0500
committerBilly Lynch <billy@chainguard.dev>2024-01-18 12:56:55 -0500
commite1bb0e2cb68265458d4540ae566c255263d918a2 (patch)
tree139795e0c80abefba237d422952d7cfa9e84deef /options.go
parenta6e934f1f76996c7f92cb4fde708170c1eb5d032 (diff)
downloadgo-git-e1bb0e2cb68265458d4540ae566c255263d918a2.tar.gz
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 <billy@chainguard.dev>
Diffstat (limited to 'options.go')
-rw-r--r--options.go5
1 files changed, 5 insertions, 0 deletions
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