MCPcopy
hub / github.com/go-git/go-git / TestDecodeFirstOccurrenceWins

Method TestDecodeFirstOccurrenceWins

plumbing/object/commit_test.go:602–733  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

600}
601
602func (s *SuiteCommit) TestDecodeFirstOccurrenceWins(c *C) {
603 const (
604 treeA = "eba74343e2f15d62adedfd8c883ee0262b5c8021"
605 treeB = "0000000000000000000000000000000000000001"
606 parentA = "35e85108805c84807bc66a02d91535e1e24b38b9"
607 parentB = "a5b8b09e2f8fcb0bb99d3ccb0958157b40890d69"
608 parentC = "0000000000000000000000000000000000000002"
609 identA = "Alice <alice@example.local> 1427802494 +0200"
610 identB = "Bob <bob@example.local> 1427802495 +0200"
611 identAuthor = "Author Name <author@example.local> 1500000000 +0000"
612 identCommit = "Commit Name <commit@example.local> 1500000001 +0000"
613 )
614
615 cases := []struct {
616 name string
617 raw string
618 assert func(*Commit)
619 }{
620 {
621 name: "duplicate tree drops the second",
622 raw: "tree " + treeA + "\ntree " + treeB +
623 "\nauthor " + identAuthor + "\ncommitter " + identCommit + "\n\nmsg\n",
624 assert: func(commit *Commit) {
625 c.Assert(commit.TreeHash.String(), Equals, treeA)
626 },
627 },
628 {
629 name: "duplicate author drops the second",
630 raw: "tree " + treeA + "\nauthor " + identA + "\nauthor " + identB +
631 "\ncommitter " + identCommit + "\n\nmsg\n",
632 assert: func(commit *Commit) {
633 c.Assert(commit.Author.Name, Equals, "Alice")
634 },
635 },
636 {
637 name: "duplicate committer drops the second",
638 raw: "tree " + treeA + "\nauthor " + identAuthor +
639 "\ncommitter " + identA + "\ncommitter " + identB + "\n\nmsg\n",
640 assert: func(commit *Commit) {
641 c.Assert(commit.Committer.Name, Equals, "Alice")
642 },
643 },
644 {
645 name: "parent after author is dropped",
646 raw: "tree " + treeA + "\nparent " + parentA +
647 "\nauthor " + identAuthor + "\nparent " + parentC +
648 "\ncommitter " + identCommit + "\n\nmsg\n",
649 assert: func(commit *Commit) {
650 c.Assert(commit.ParentHashes, DeepEquals, []plumbing.Hash{plumbing.NewHash(parentA)})
651 },
652 },
653 {
654 name: "parent interleaved with extras is dropped",
655 raw: "tree " + treeA + "\nparent " + parentA + "\nparent " + parentB +
656 "\nx-other thing\nparent " + parentC +
657 "\nauthor " + identAuthor + "\ncommitter " + identCommit + "\n\nmsg\n",
658 assert: func(commit *Commit) {
659 c.Assert(commit.ParentHashes, DeepEquals, []plumbing.Hash{

Callers

nothing calls this directly

Calls 7

SetTypeMethod · 0.95
WriteMethod · 0.95
DecodeMethod · 0.95
NewHashFunction · 0.92
MessageEncodingTypeAlias · 0.85
LogMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected