aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-02-20 22:59:14 +0800
committerGravatar Runxi Yu2026-02-20 22:59:14 +0800
commitd88c8e20aebd9408df0306e97dffc2896950342d (patch)
tree8e137f37fdd9ea673bd622a2b9c9873cd89278fb /internal
parentobjectid: Use _test package for tests (diff)
signatureNo signature
*: Replace repo with testRepo
Diffstat (limited to 'internal')
-rw-r--r--internal/testgit/repo_cat_file.go4
-rw-r--r--internal/testgit/repo_commit_tree.go6
-rw-r--r--internal/testgit/repo_hash_object.go6
-rw-r--r--internal/testgit/repo_make_commit.go6
-rw-r--r--internal/testgit/repo_make_single_file_tree.go6
-rw-r--r--internal/testgit/repo_mktree.go6
-rw-r--r--internal/testgit/repo_new.go6
-rw-r--r--internal/testgit/repo_properties.go8
-rw-r--r--internal/testgit/repo_rev_parse.go6
-rw-r--r--internal/testgit/repo_run.go20
-rw-r--r--internal/testgit/repo_tag_annotated.go6
11 files changed, 40 insertions, 40 deletions
diff --git a/internal/testgit/repo_cat_file.go b/internal/testgit/repo_cat_file.go
index c905521f..9cc56db6 100644
--- a/internal/testgit/repo_cat_file.go
+++ b/internal/testgit/repo_cat_file.go
@@ -7,7 +7,7 @@ import (
)
// CatFile returns raw output from git cat-file.
-func (repo *TestRepo) CatFile(tb testing.TB, mode string, id objectid.ObjectID) []byte {
+func (testRepo *TestRepo) CatFile(tb testing.TB, mode string, id objectid.ObjectID) []byte {
tb.Helper()
- return repo.RunBytes(tb, "cat-file", mode, id.String())
+ return testRepo.RunBytes(tb, "cat-file", mode, id.String())
}
diff --git a/internal/testgit/repo_commit_tree.go b/internal/testgit/repo_commit_tree.go
index 1b33b5c0..f8d78421 100644
--- a/internal/testgit/repo_commit_tree.go
+++ b/internal/testgit/repo_commit_tree.go
@@ -7,15 +7,15 @@ import (
)
// CommitTree creates a commit from a tree and message, optionally with parents.
-func (repo *TestRepo) CommitTree(tb testing.TB, tree objectid.ObjectID, message string, parents ...objectid.ObjectID) objectid.ObjectID {
+func (testRepo *TestRepo) CommitTree(tb testing.TB, tree objectid.ObjectID, message string, parents ...objectid.ObjectID) objectid.ObjectID {
tb.Helper()
args := []string{"commit-tree", tree.String()}
for _, p := range parents {
args = append(args, "-p", p.String())
}
args = append(args, "-m", message)
- hex := repo.Run(tb, args...)
- id, err := objectid.ParseHex(repo.algo, hex)
+ hex := testRepo.Run(tb, args...)
+ id, err := objectid.ParseHex(testRepo.algo, hex)
if err != nil {
tb.Fatalf("parse commit-tree output %q: %v", hex, err)
}
diff --git a/internal/testgit/repo_hash_object.go b/internal/testgit/repo_hash_object.go
index b21e1231..10a05381 100644
--- a/internal/testgit/repo_hash_object.go
+++ b/internal/testgit/repo_hash_object.go
@@ -7,10 +7,10 @@ import (
)
// HashObject hashes and writes an object and returns its object ID.
-func (repo *TestRepo) HashObject(tb testing.TB, objType string, body []byte) objectid.ObjectID {
+func (testRepo *TestRepo) HashObject(tb testing.TB, objType string, body []byte) objectid.ObjectID {
tb.Helper()
- hex := repo.RunInput(tb, body, "hash-object", "-t", objType, "-w", "--stdin")
- id, err := objectid.ParseHex(repo.algo, hex)
+ hex := testRepo.RunInput(tb, body, "hash-object", "-t", objType, "-w", "--stdin")
+ id, err := objectid.ParseHex(testRepo.algo, hex)
if err != nil {
tb.Fatalf("parse git hash-object output %q: %v", hex, err)
}
diff --git a/internal/testgit/repo_make_commit.go b/internal/testgit/repo_make_commit.go
index 35619334..a569dfb1 100644
--- a/internal/testgit/repo_make_commit.go
+++ b/internal/testgit/repo_make_commit.go
@@ -7,9 +7,9 @@ import (
)
// MakeCommit creates a commit over a single-file tree and returns (blobID, treeID, commitID).
-func (repo *TestRepo) MakeCommit(tb testing.TB, message string) (objectid.ObjectID, objectid.ObjectID, objectid.ObjectID) {
+func (testRepo *TestRepo) MakeCommit(tb testing.TB, message string) (objectid.ObjectID, objectid.ObjectID, objectid.ObjectID) {
tb.Helper()
- blobID, treeID := repo.MakeSingleFileTree(tb, "file.txt", []byte("commit-body\n"))
- commitID := repo.CommitTree(tb, treeID, message)
+ blobID, treeID := testRepo.MakeSingleFileTree(tb, "file.txt", []byte("commit-body\n"))
+ commitID := testRepo.CommitTree(tb, treeID, message)
return blobID, treeID, commitID
}
diff --git a/internal/testgit/repo_make_single_file_tree.go b/internal/testgit/repo_make_single_file_tree.go
index a0ccce9b..7c53c658 100644
--- a/internal/testgit/repo_make_single_file_tree.go
+++ b/internal/testgit/repo_make_single_file_tree.go
@@ -8,10 +8,10 @@ import (
)
// 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) {
+func (testRepo *TestRepo) MakeSingleFileTree(tb testing.TB, fileName string, fileContent []byte) (objectid.ObjectID, objectid.ObjectID) {
tb.Helper()
- blobID := repo.HashObject(tb, "blob", fileContent)
+ blobID := testRepo.HashObject(tb, "blob", fileContent)
treeInput := fmt.Sprintf("100644 blob %s\t%s\n", blobID.String(), fileName)
- treeID := repo.Mktree(tb, treeInput)
+ treeID := testRepo.Mktree(tb, treeInput)
return blobID, treeID
}
diff --git a/internal/testgit/repo_mktree.go b/internal/testgit/repo_mktree.go
index 0d3f0ea7..34e6388d 100644
--- a/internal/testgit/repo_mktree.go
+++ b/internal/testgit/repo_mktree.go
@@ -7,10 +7,10 @@ import (
)
// Mktree creates a tree from textual mktree input and returns its ID.
-func (repo *TestRepo) Mktree(tb testing.TB, input string) objectid.ObjectID {
+func (testRepo *TestRepo) Mktree(tb testing.TB, input string) objectid.ObjectID {
tb.Helper()
- hex := repo.RunInput(tb, []byte(input), "mktree")
- id, err := objectid.ParseHex(repo.algo, hex)
+ hex := testRepo.RunInput(tb, []byte(input), "mktree")
+ id, err := objectid.ParseHex(testRepo.algo, hex)
if err != nil {
tb.Fatalf("parse mktree output %q: %v", hex, err)
}
diff --git a/internal/testgit/repo_new.go b/internal/testgit/repo_new.go
index 308d8156..8908c8c0 100644
--- a/internal/testgit/repo_new.go
+++ b/internal/testgit/repo_new.go
@@ -31,7 +31,7 @@ func newRepo(tb testing.TB, algo objectid.Algorithm, bare bool) *TestRepo {
}
tb.Cleanup(func() { _ = os.RemoveAll(dir) })
- repo := &TestRepo{
+ testRepo := &TestRepo{
dir: dir,
algo: algo,
env: append(os.Environ(),
@@ -51,6 +51,6 @@ func newRepo(tb testing.TB, algo objectid.Algorithm, bare bool) *TestRepo {
args = append(args, "--bare")
}
args = append(args, dir)
- repo.runBytes(tb, nil, "", args...)
- return repo
+ testRepo.runBytes(tb, nil, "", args...)
+ return testRepo
}
diff --git a/internal/testgit/repo_properties.go b/internal/testgit/repo_properties.go
index a25c329c..47123ee8 100644
--- a/internal/testgit/repo_properties.go
+++ b/internal/testgit/repo_properties.go
@@ -3,11 +3,11 @@ package testgit
import "codeberg.org/lindenii/furgit/objectid"
// Dir returns the repository directory path.
-func (repo *TestRepo) Dir() string {
- return repo.dir
+func (testRepo *TestRepo) Dir() string {
+ return testRepo.dir
}
// Algorithm returns the object ID algorithm configured for this repository.
-func (repo *TestRepo) Algorithm() objectid.Algorithm {
- return repo.algo
+func (testRepo *TestRepo) Algorithm() objectid.Algorithm {
+ return testRepo.algo
}
diff --git a/internal/testgit/repo_rev_parse.go b/internal/testgit/repo_rev_parse.go
index d545f97b..bebdfa8e 100644
--- a/internal/testgit/repo_rev_parse.go
+++ b/internal/testgit/repo_rev_parse.go
@@ -7,10 +7,10 @@ import (
)
// RevParse resolves rev expressions to object IDs.
-func (repo *TestRepo) RevParse(tb testing.TB, spec string) objectid.ObjectID {
+func (testRepo *TestRepo) RevParse(tb testing.TB, spec string) objectid.ObjectID {
tb.Helper()
- hex := repo.Run(tb, "rev-parse", spec)
- id, err := objectid.ParseHex(repo.algo, hex)
+ hex := testRepo.Run(tb, "rev-parse", spec)
+ id, err := objectid.ParseHex(testRepo.algo, hex)
if err != nil {
tb.Fatalf("parse rev-parse output %q: %v", hex, err)
}
diff --git a/internal/testgit/repo_run.go b/internal/testgit/repo_run.go
index 66222569..aafcc923 100644
--- a/internal/testgit/repo_run.go
+++ b/internal/testgit/repo_run.go
@@ -8,36 +8,36 @@ import (
)
// Run executes git and returns trimmed textual output.
-func (repo *TestRepo) Run(tb testing.TB, args ...string) string {
+func (testRepo *TestRepo) Run(tb testing.TB, args ...string) string {
tb.Helper()
- out := repo.runBytes(tb, nil, repo.dir, args...)
+ out := testRepo.runBytes(tb, nil, testRepo.dir, args...)
return strings.TrimSpace(string(out))
}
// RunBytes executes git and returns raw output bytes.
-func (repo *TestRepo) RunBytes(tb testing.TB, args ...string) []byte {
+func (testRepo *TestRepo) RunBytes(tb testing.TB, args ...string) []byte {
tb.Helper()
- return repo.runBytes(tb, nil, repo.dir, args...)
+ return testRepo.runBytes(tb, nil, testRepo.dir, args...)
}
// RunInput executes git with stdin and returns trimmed textual output.
-func (repo *TestRepo) RunInput(tb testing.TB, stdin []byte, args ...string) string {
+func (testRepo *TestRepo) RunInput(tb testing.TB, stdin []byte, args ...string) string {
tb.Helper()
- out := repo.runBytes(tb, stdin, repo.dir, args...)
+ out := testRepo.runBytes(tb, stdin, testRepo.dir, args...)
return strings.TrimSpace(string(out))
}
// RunInputBytes executes git with stdin and returns raw output bytes.
-func (repo *TestRepo) RunInputBytes(tb testing.TB, stdin []byte, args ...string) []byte {
+func (testRepo *TestRepo) RunInputBytes(tb testing.TB, stdin []byte, args ...string) []byte {
tb.Helper()
- return repo.runBytes(tb, stdin, repo.dir, args...)
+ return testRepo.runBytes(tb, stdin, testRepo.dir, args...)
}
-func (repo *TestRepo) runBytes(tb testing.TB, stdin []byte, dir string, args ...string) []byte {
+func (testRepo *TestRepo) runBytes(tb testing.TB, stdin []byte, dir string, args ...string) []byte {
tb.Helper()
cmd := exec.Command("git", args...)
cmd.Dir = dir
- cmd.Env = repo.env
+ cmd.Env = testRepo.env
if stdin != nil {
cmd.Stdin = bytes.NewReader(stdin)
}
diff --git a/internal/testgit/repo_tag_annotated.go b/internal/testgit/repo_tag_annotated.go
index 3db6cee9..a3ffafa6 100644
--- a/internal/testgit/repo_tag_annotated.go
+++ b/internal/testgit/repo_tag_annotated.go
@@ -8,8 +8,8 @@ import (
)
// TagAnnotated creates an annotated tag object and returns the resulting tag object ID.
-func (repo *TestRepo) TagAnnotated(tb testing.TB, name string, target objectid.ObjectID, message string) objectid.ObjectID {
+func (testRepo *TestRepo) TagAnnotated(tb testing.TB, name string, target objectid.ObjectID, message string) objectid.ObjectID {
tb.Helper()
- repo.Run(tb, "tag", "-a", name, target.String(), "-m", message)
- return repo.RevParse(tb, fmt.Sprintf("refs/tags/%s", name))
+ testRepo.Run(tb, "tag", "-a", name, target.String(), "-m", message)
+ return testRepo.RevParse(tb, fmt.Sprintf("refs/tags/%s", name))
}