diff options
| author | 2026-03-28 18:01:38 +0000 | |
|---|---|---|
| committer | 2026-03-28 18:01:38 +0000 | |
| commit | 8c135d16610a9da49c0cd41220125c7a2a06a105 (patch) | |
| tree | b90f5bded6b81dbb9a08c55111224833c9c30292 | |
| parent | reachability: Document contract (diff) | |
| signature | No signature | |
reachability: Don't have a separate New for commit graphs
| -rw-r--r-- | reachability/integration_test.go | 2 | ||||
| -rw-r--r-- | reachability/reachability.go | 13 | ||||
| -rw-r--r-- | reachability/unit_test.go | 14 |
3 files changed, 11 insertions, 18 deletions
diff --git a/reachability/integration_test.go b/reachability/integration_test.go index 4c57d14f..4e4b3918 100644 --- a/reachability/integration_test.go +++ b/reachability/integration_test.go @@ -249,7 +249,7 @@ func TestWalkOnPackedOnlyRepo(t *testing.T) { func openReachabilityFromTestRepo(t *testing.T, testRepo *testgit.TestRepo) *reachability.Reachability { t.Helper() - return reachability.New(testRepo.OpenObjectStore(t)) + return reachability.New(testRepo.OpenObjectStore(t), nil) } func oidSetFromSeq(seq func(func(objectid.ObjectID) bool)) map[objectid.ObjectID]struct{} { diff --git a/reachability/reachability.go b/reachability/reachability.go index 2fa29ad1..6932016b 100644 --- a/reachability/reachability.go +++ b/reachability/reachability.go @@ -14,17 +14,10 @@ type Reachability struct { graph *commitgraphread.Reader } -// New builds a Reachability over one object store. +// New builds a Reachability over one object store with an optional +// commit-graph reader for faster commit-domain traversal. // // Labels: Deps-Borrowed. -func New(store objectstore.ReadingStore) *Reachability { - return &Reachability{store: store} -} - -// NewWithCommitGraph builds a Reachability over one object store with an -// optional commit-graph reader for faster commit-domain traversal. -// -// Labels: Deps-Borrowed. -func NewWithCommitGraph(store objectstore.ReadingStore, graph *commitgraphread.Reader) *Reachability { +func New(store objectstore.ReadingStore, graph *commitgraphread.Reader) *Reachability { return &Reachability{store: store, graph: graph} } diff --git a/reachability/unit_test.go b/reachability/unit_test.go index dcd5350b..61794a5b 100644 --- a/reachability/unit_test.go +++ b/reachability/unit_test.go @@ -94,7 +94,7 @@ func TestWalkDomainCommitsIncludesTagNodes(t *testing.T) { tag1 := store.AddObject(objecttype.TypeTag, tagBody(commit2, objecttype.TypeCommit)) tag2 := store.AddObject(objecttype.TypeTag, tagBody(tag1, objecttype.TypeTag)) - r := reachability.New(store) + r := reachability.New(store, nil) walk := r.Walk(reachability.DomainCommits, nil, map[objectid.ObjectID]struct{}{tag2: {}}) got := collectSeq(walk.Seq()) @@ -126,7 +126,7 @@ func TestWalkExcludesHavesCompletely(t *testing.T) { }}})) commit := store.AddObject(objecttype.TypeCommit, commitBody(tree)) - r := reachability.New(store) + r := reachability.New(store, nil) walk := r.Walk(reachability.DomainCommits, map[objectid.ObjectID]struct{}{commit: {}}, map[objectid.ObjectID]struct{}{commit: {}}) got := collectSeq(walk.Seq()) @@ -155,7 +155,7 @@ func TestWalkDomainCommitsRejectsNonCommitRootAfterPeel(t *testing.T) { }}})) tag := store.AddObject(objecttype.TypeTag, tagBody(tree, objecttype.TypeTree)) - r := reachability.New(store) + r := reachability.New(store, nil) walk := r.Walk(reachability.DomainCommits, nil, map[objectid.ObjectID]struct{}{tag: {}}) _ = collectSeq(walk.Seq()) @@ -191,7 +191,7 @@ func TestWalkDomainCommitsHaveTagStopsTraversal(t *testing.T) { tag1 := store.AddObject(objecttype.TypeTag, tagBody(commit2, objecttype.TypeCommit)) tag2 := store.AddObject(objecttype.TypeTag, tagBody(tag1, objecttype.TypeTag)) - r := reachability.New(store) + r := reachability.New(store, nil) walk := r.Walk( reachability.DomainCommits, map[objectid.ObjectID]struct{}{tag1: {}}, @@ -236,7 +236,7 @@ func TestWalkDomainObjectsRecursesTreesAndSkipsBlobContentReads(t *testing.T) { }})) commit := store.AddObject(objecttype.TypeCommit, commitBody(rootTree)) - r := reachability.New(store) + r := reachability.New(store, nil) walk := r.Walk(reachability.DomainObjects, nil, map[objectid.ObjectID]struct{}{commit: {}}) got := collectSeq(walk.Seq()) @@ -273,7 +273,7 @@ func TestCheckConnectedReturnsConcreteMissingObject(t *testing.T) { missingParent := store.Algorithm().Sum([]byte("missing-parent")) commit := store.AddObject(objecttype.TypeCommit, commitBody(tree, missingParent)) - r := reachability.New(store) + r := reachability.New(store, nil) err := r.CheckConnected(reachability.DomainCommits, nil, map[objectid.ObjectID]struct{}{commit: {}}) if err == nil { @@ -295,7 +295,7 @@ func TestWalkInvalidDomainReturnsPlainError(t *testing.T) { t.Parallel() testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { //nolint:thelper - r := reachability.New(newCountingMemStore(algo)) + r := reachability.New(newCountingMemStore(algo), nil) walk := r.Walk(reachability.Domain(99), nil, nil) _ = collectSeq(walk.Seq()) |
