aboutsummaryrefslogtreecommitdiff
path: root/internal/testgit/repo_make_single_file_tree.go
blob: a0ccce9b325b15dd9f5aa66eebffe3d70f6c1346 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package testgit

import (
	"fmt"
	"testing"

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

// MakeSingleFileTree writes one blob and one tree entry for it and returns (blobID, treeID).
func (repo *TestRepo) MakeSingleFileTree(tb testing.TB, fileName string, fileContent []byte) (objectid.ObjectID, objectid.ObjectID) {
	tb.Helper()
	blobID := repo.HashObject(tb, "blob", fileContent)
	treeInput := fmt.Sprintf("100644 blob %s\t%s\n", blobID.String(), fileName)
	treeID := repo.Mktree(tb, treeInput)
	return blobID, treeID
}