refactor: remove Ctx field from git.Repository (#38500)

This commit is contained in:
wxiaoguang
2026-07-17 18:44:31 +08:00
committed by GitHub
parent 2c8e99bbf7
commit 5b078f72aa
235 changed files with 1234 additions and 1258 deletions
+5 -5
View File
@@ -11,11 +11,11 @@ import (
)
func TestSubTree_Issue29101(t *testing.T) {
repo, err := OpenRepository(t.Context(), filepath.Join(testReposDir, "repo1_bare"))
repo, err := OpenRepository(filepath.Join(testReposDir, "repo1_bare"))
assert.NoError(t, err)
defer repo.Close()
commit, err := repo.GetCommit("ce064814f4a0d337b333e646ece456cd39fab612")
commit, err := repo.GetCommit(t.Context(), "ce064814f4a0d337b333e646ece456cd39fab612")
assert.NoError(t, err)
// old code could produce a different error if called multiple times
@@ -27,15 +27,15 @@ func TestSubTree_Issue29101(t *testing.T) {
}
func Test_GetTreePathLatestCommit(t *testing.T) {
repo, err := OpenRepository(t.Context(), filepath.Join(testReposDir, "repo6_blame"))
repo, err := OpenRepository(filepath.Join(testReposDir, "repo6_blame"))
assert.NoError(t, err)
defer repo.Close()
commitID, err := repo.GetBranchCommitID("master")
commitID, err := repo.GetBranchCommitID(t.Context(), "master")
assert.NoError(t, err)
assert.Equal(t, "544d8f7a3b15927cddf2299b4b562d6ebd71b6a7", commitID)
commit, err := repo.GetTreePathLatestCommit("master", "blame.txt")
commit, err := repo.GetTreePathLatestCommit(t.Context(), "master", "blame.txt")
assert.NoError(t, err)
assert.NotNil(t, commit)
assert.Equal(t, "45fb6cbc12f970b04eacd5cd4165edd11c8d7376", commit.ID.String())