aboutsummaryrefslogtreecommitdiffstats
path: root/options.go
diff options
context:
space:
mode:
authorBilly Lynch <billy@chainguard.dev>2024-02-13 15:33:37 -0500
committerBilly Lynch <billy@chainguard.dev>2024-02-13 15:56:28 -0500
commit9fa13d83c6e473d0aca7b97a620b3f4a003993f6 (patch)
treebb994824c5dc8fcad5500a9832ea57046d4684cc /options.go
parent0dfff253b0b0ad7886d82bf9713e738e1045df1b (diff)
downloadgo-git-9fa13d83c6e473d0aca7b97a620b3f4a003993f6.tar.gz
git: signer, fix usage of crypto.Signer interface
crypto.Signer was incorrectly used before. Signer documentation says that Signer.Sign should be used on digests, whereas we were using this on message bodies. To fix this, create our own Signer interface (+ signableObject borrowed from #705) that describes more accurately what we want. As before, the expectation is that signer implementations only need to worry about acting on encoded message bodies rather than needing to encode objects themselves. This is technically a breaking change from the previous Signer implementation, but since this is new and hasn't made it into cut release yet, this seems like an acceptible change. Also adds example test showing how signers can be made (uses base64 for consistent outputs).
Diffstat (limited to 'options.go')
-rw-r--r--options.go3
1 files changed, 1 insertions, 2 deletions
diff --git a/options.go b/options.go
index 0a6eb94..4f913dc 100644
--- a/options.go
+++ b/options.go
@@ -1,7 +1,6 @@
package git
import (
- "crypto"
"errors"
"fmt"
"regexp"
@@ -516,7 +515,7 @@ type CommitOptions struct {
// 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
+ Signer 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