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
+6 -5
View File
@@ -118,7 +118,8 @@ func expectedAttrs() *Attributes {
func Test_BatchChecker(t *testing.T) {
setting.AppDataPath = t.TempDir()
repoPath := "../tests/repos/language_stats_repo"
gitRepo, err := git.OpenRepository(t.Context(), repoPath)
ctx := t.Context()
gitRepo, err := git.OpenRepository(repoPath)
require.NoError(t, err)
defer gitRepo.Close()
@@ -126,7 +127,7 @@ func Test_BatchChecker(t *testing.T) {
t.Run("Create index file to run git check-attr", func(t *testing.T) {
defer test.MockVariableValue(&git.DefaultFeatures().SupportCheckAttrOnBare, false)()
checker, err := NewBatchChecker(gitRepo, commitID, LinguistAttributes)
checker, err := NewBatchChecker(ctx, gitRepo, commitID, LinguistAttributes)
assert.NoError(t, err)
defer checker.Close()
attributes, err := checker.CheckPath("i-am-a-python.p")
@@ -143,11 +144,11 @@ func Test_BatchChecker(t *testing.T) {
})
assert.NoError(t, err)
tempRepo, err := git.OpenRepository(t.Context(), dir)
tempRepo, err := git.OpenRepository(dir)
assert.NoError(t, err)
defer tempRepo.Close()
checker, err := NewBatchChecker(tempRepo, "", LinguistAttributes)
checker, err := NewBatchChecker(t.Context(), tempRepo, "", LinguistAttributes)
assert.NoError(t, err)
defer checker.Close()
attributes, err := checker.CheckPath("i-am-a-python.p")
@@ -161,7 +162,7 @@ func Test_BatchChecker(t *testing.T) {
}
t.Run("Run git check-attr in bare repository", func(t *testing.T) {
checker, err := NewBatchChecker(gitRepo, commitID, LinguistAttributes)
checker, err := NewBatchChecker(ctx, gitRepo, commitID, LinguistAttributes)
assert.NoError(t, err)
defer checker.Close()