From a04488c786baffa1faea9f501349fa63c28931a1 Mon Sep 17 00:00:00 2001 From: Antoine GIRARD Date: Mon, 22 Apr 2019 00:59:47 +0200 Subject: plumbing: object/{commit,tag} add EncodeWithoutSignature, Implement #1116 Signed-off-by: Antoine GIRARD --- plumbing/object/commit.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'plumbing/object/commit.go') diff --git a/plumbing/object/commit.go b/plumbing/object/commit.go index 511242d..6b50934 100644 --- a/plumbing/object/commit.go +++ b/plumbing/object/commit.go @@ -235,6 +235,11 @@ func (b *Commit) Encode(o plumbing.EncodedObject) error { return b.encode(o, true) } +// EncodeWithoutSignature export a Commit into a plumbing.EncodedObject without the signature (correspond to the payload of the PGP signature). +func (b *Commit) EncodeWithoutSignature(o plumbing.EncodedObject) error { + return b.encode(o, false) +} + func (b *Commit) encode(o plumbing.EncodedObject, includeSig bool) (err error) { o.SetType(plumbing.CommitObject) w, err := o.Writer() @@ -349,7 +354,7 @@ func (c *Commit) Verify(armoredKeyRing string) (*openpgp.Entity, error) { encoded := &plumbing.MemoryObject{} // Encode commit components, excluding signature and get a reader object. - if err := c.encode(encoded, false); err != nil { + if err := c.EncodeWithoutSignature(encoded); err != nil { return nil, err } er, err := encoded.Reader() -- cgit