aboutsummaryrefslogtreecommitdiff
path: root/internal/testgit/repo_open_repository.go
blob: fbc98383ca70e5dd26c03d7d0e646d9d87248a92 (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
package testgit

import (
	"testing"

	"codeberg.org/lindenii/furgit/repository"
)

// OpenRepository opens the repository and registers cleanup on the caller.
func (testRepo *TestRepo) OpenRepository(tb testing.TB) *repository.Repository {
	tb.Helper()

	root := testRepo.OpenGitRoot(tb)

	repo, err := repository.Open(root)
	if err != nil {
		tb.Fatalf("repository.Open: %v", err)
	}

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

	return repo
}