(c *C, index commitgraph.Index)
| 35 | } |
| 36 | |
| 37 | func testDecodeHelper(c *C, index commitgraph.Index) { |
| 38 | // Root commit |
| 39 | nodeIndex, err := index.GetIndexByHash(plumbing.NewHash("347c91919944a68e9413581a1bc15519550a3afe")) |
| 40 | c.Assert(err, IsNil) |
| 41 | commitData, err := index.GetCommitDataByIndex(nodeIndex) |
| 42 | c.Assert(err, IsNil) |
| 43 | c.Assert(len(commitData.ParentIndexes), Equals, 0) |
| 44 | c.Assert(len(commitData.ParentHashes), Equals, 0) |
| 45 | |
| 46 | // Regular commit |
| 47 | nodeIndex, err = index.GetIndexByHash(plumbing.NewHash("e713b52d7e13807e87a002e812041f248db3f643")) |
| 48 | c.Assert(err, IsNil) |
| 49 | commitData, err = index.GetCommitDataByIndex(nodeIndex) |
| 50 | c.Assert(err, IsNil) |
| 51 | c.Assert(len(commitData.ParentIndexes), Equals, 1) |
| 52 | c.Assert(len(commitData.ParentHashes), Equals, 1) |
| 53 | c.Assert(commitData.ParentHashes[0].String(), Equals, "347c91919944a68e9413581a1bc15519550a3afe") |
| 54 | |
| 55 | // Merge commit |
| 56 | nodeIndex, err = index.GetIndexByHash(plumbing.NewHash("b29328491a0682c259bcce28741eac71f3499f7d")) |
| 57 | c.Assert(err, IsNil) |
| 58 | commitData, err = index.GetCommitDataByIndex(nodeIndex) |
| 59 | c.Assert(err, IsNil) |
| 60 | c.Assert(len(commitData.ParentIndexes), Equals, 2) |
| 61 | c.Assert(len(commitData.ParentHashes), Equals, 2) |
| 62 | c.Assert(commitData.ParentHashes[0].String(), Equals, "e713b52d7e13807e87a002e812041f248db3f643") |
| 63 | c.Assert(commitData.ParentHashes[1].String(), Equals, "03d2c021ff68954cf3ef0a36825e194a4b98f981") |
| 64 | |
| 65 | // Octopus merge commit |
| 66 | nodeIndex, err = index.GetIndexByHash(plumbing.NewHash("6f6c5d2be7852c782be1dd13e36496dd7ad39560")) |
| 67 | c.Assert(err, IsNil) |
| 68 | commitData, err = index.GetCommitDataByIndex(nodeIndex) |
| 69 | c.Assert(err, IsNil) |
| 70 | c.Assert(len(commitData.ParentIndexes), Equals, 3) |
| 71 | c.Assert(len(commitData.ParentHashes), Equals, 3) |
| 72 | c.Assert(commitData.ParentHashes[0].String(), Equals, "ce275064ad67d51e99f026084e20827901a8361c") |
| 73 | c.Assert(commitData.ParentHashes[1].String(), Equals, "bb13916df33ed23004c3ce9ed3b8487528e655c1") |
| 74 | c.Assert(commitData.ParentHashes[2].String(), Equals, "a45273fe2d63300e1962a9e26a6b15c276cd7082") |
| 75 | |
| 76 | // Check all hashes |
| 77 | hashes := index.Hashes() |
| 78 | c.Assert(len(hashes), Equals, 11) |
| 79 | c.Assert(hashes[0].String(), Equals, "03d2c021ff68954cf3ef0a36825e194a4b98f981") |
| 80 | c.Assert(hashes[10].String(), Equals, "e713b52d7e13807e87a002e812041f248db3f643") |
| 81 | } |
| 82 | |
| 83 | func (s *CommitgraphSuite) TestDecodeMultiChain(c *C) { |
| 84 | fixtures.ByTag("commit-graph-chain-2").Test(c, func(f *fixtures.Fixture) { |
no test coverage detected
searching dependent graphs…