MCPcopy Create free account
hub / github.com/entireio/git-sync / writeLinearCommitChain

Function writeLinearCommitChain

internal/strategy/bootstrap/bootstrap_test.go:1727–1754  ·  view source on GitHub ↗
(tb testing.TB, store storer.Storer, count int)

Source from the content-addressed store, hash-verified

1725}
1726
1727func writeLinearCommitChain(tb testing.TB, store storer.Storer, count int) []plumbing.Hash {
1728 tb.Helper()
1729 hashes := make([]plumbing.Hash, 0, count)
1730 for i := range count {
1731 obj := store.NewEncodedObject()
1732 var parents []plumbing.Hash
1733 if len(hashes) > 0 {
1734 parents = []plumbing.Hash{hashes[len(hashes)-1]}
1735 }
1736 when := time.Unix(int64(i+1), 0).UTC()
1737 commit := &object.Commit{
1738 Author: object.Signature{Name: "test", Email: "test@example.com", When: when},
1739 Committer: object.Signature{Name: "test", Email: "test@example.com", When: when},
1740 Message: fmt.Sprintf("commit-%d", i),
1741 TreeHash: plumbing.ZeroHash,
1742 ParentHashes: parents,
1743 }
1744 if err := commit.Encode(obj); err != nil {
1745 tb.Fatalf("encode commit %d: %v", i, err)
1746 }
1747 hash, err := store.SetEncodedObject(obj)
1748 if err != nil {
1749 tb.Fatalf("store commit %d: %v", i, err)
1750 }
1751 hashes = append(hashes, hash)
1752 }
1753 return hashes
1754}

Calls 2

NewEncodedObjectMethod · 0.80
SetEncodedObjectMethod · 0.80

Tested by

no test coverage detected