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

import (
	"fmt"
	"testing"

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

// RemoveLooseObject removes one loose object file from the repository.
func (testRepo *TestRepo) RemoveLooseObject(tb testing.TB, id objectid.ObjectID) {
	tb.Helper()

	root := testRepo.OpenObjectsRoot(tb)
	hex := id.String()
	path := fmt.Sprintf("%s/%s", hex[:2], hex[2:])

	err := root.Remove(path)
	if err != nil {
		tb.Fatalf("remove loose object %s: %v", id, err)
	}
}