aboutsummaryrefslogtreecommitdiff
path: root/internal/testgit/repo_open_commit_graph.go
blob: 6c0fee4ab830a2b4d6d5288989182d2660e9db5e (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package testgit

import (
	"testing"

	commitgraphread "codeberg.org/lindenii/furgit/commitgraph/read"
)

// OpenCommitGraph opens the repository commit-graph and registers cleanup on
// the caller.
func (testRepo *TestRepo) OpenCommitGraph(tb testing.TB) *commitgraphread.Reader {
	tb.Helper()

	objectsRoot := testRepo.OpenObjectsRoot(tb)

	graph, err := commitgraphread.Open(objectsRoot, testRepo.Algorithm(), commitgraphread.OpenSingle)
	if err != nil {
		tb.Fatalf("commitgraphread.Open: %v", err)
	}

	tb.Cleanup(func() {
		_ = graph.Close()
	})

	return graph
}