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
+4 -4
View File
@@ -33,7 +33,7 @@ func SyncRepoBranches(ctx context.Context, repoID, doerID int64) (int64, error)
log.Debug("SyncRepoBranches: in Repo[%d:%s]", repo.ID, repo.FullName())
gitRepo, err := gitrepo.OpenRepository(ctx, repo)
gitRepo, err := gitrepo.OpenRepository(repo)
if err != nil {
log.Error("OpenRepository[%s]: %w", repo.FullName(), err)
return 0, err
@@ -45,7 +45,7 @@ func SyncRepoBranches(ctx context.Context, repoID, doerID int64) (int64, error)
}
func SyncRepoBranchesWithRepo(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, doerID int64) (int64, []*SyncResult, error) {
objFmt, err := gitRepo.GetObjectFormat()
objFmt, err := gitRepo.GetObjectFormat(ctx)
if err != nil {
return 0, nil, fmt.Errorf("GetObjectFormat: %w", err)
}
@@ -58,7 +58,7 @@ func SyncRepoBranchesWithRepo(ctx context.Context, repo *repo_model.Repository,
allBranches := container.Set[string]{}
{
branches, _, err := gitRepo.GetBranchNames(0, 0)
branches, _, err := gitRepo.GetBranchNames(ctx, 0, 0)
if err != nil {
return 0, nil, err
}
@@ -88,7 +88,7 @@ func SyncRepoBranchesWithRepo(ctx context.Context, repo *repo_model.Repository,
var syncResults []*SyncResult
for branch := range allBranches {
dbb := dbBranches[branch]
commit, err := gitRepo.GetBranchCommit(branch)
commit, err := gitRepo.GetBranchCommit(ctx, branch)
if err != nil {
return 0, nil, err
}
+2 -2
View File
@@ -47,7 +47,7 @@ func SyncRepoTags(ctx context.Context, repoID int64) error {
return err
}
gitRepo, err := gitrepo.OpenRepository(ctx, repo)
gitRepo, err := gitrepo.OpenRepository(repo)
if err != nil {
return err
}
@@ -181,7 +181,7 @@ func (shortRelease) TableName() string {
// repositories like https://github.com/vim/vim (with over 13000 tags).
func SyncReleasesWithTags(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository) ([]*SyncResult, error) {
log.Debug("SyncReleasesWithTags: in Repo[%d:%s/%s]", repo.ID, repo.OwnerName, repo.Name)
tags, _, err := gitRepo.GetTagInfos(0, 0)
tags, _, err := gitRepo.GetTagInfos(ctx, 0, 0)
if err != nil {
return nil, fmt.Errorf("unable to GetTagInfos in pull-mirror Repo[%d:%s/%s]: %w", repo.ID, repo.OwnerName, repo.Name, err)
}