shithub: furgit

ref: 3ce59c3248dec0eb0f918c42f37f53bc2ac20425
dir: /internal/testgit/repo_open_commit_graph.go/

View raw version
package testgit

import (
	"testing"

	commitgraphread "codeberg.org/lindenii/furgit/format/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
}