MCPcopy Create free account
hub / github.com/go-git/go-git / Verify

Method Verify

plumbing/object/commit.go:411–432  ·  view source on GitHub ↗

Verify performs PGP verification of the commit with a provided armored keyring and returns openpgp.Entity associated with verifying key on success.

(armoredKeyRing string)

Source from the content-addressed store, hash-verified

409// Verify performs PGP verification of the commit with a provided armored
410// keyring and returns openpgp.Entity associated with verifying key on success.
411func (c *Commit) Verify(armoredKeyRing string) (*openpgp.Entity, error) {
412 keyRingReader := strings.NewReader(armoredKeyRing)
413 keyring, err := openpgp.ReadArmoredKeyRing(keyRingReader)
414 if err != nil {
415 return nil, err
416 }
417
418 // Extract signature.
419 signature := strings.NewReader(c.PGPSignature)
420
421 encoded := &plumbing.MemoryObject{}
422 // Encode commit components, excluding signature and get a reader object.
423 if err := c.EncodeWithoutSignature(encoded); err != nil {
424 return nil, err
425 }
426 er, err := encoded.Reader()
427 if err != nil {
428 return nil, err
429 }
430
431 return openpgp.CheckArmoredDetachedSignature(keyring, er, signature, nil)
432}
433
434// Less defines a compare function to determine which commit is 'earlier' by:
435// - First use Committer.When

Callers 1

TestVerifyMethod · 0.95

Calls 2

ReaderMethod · 0.95

Tested by 1

TestVerifyMethod · 0.76