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
+7 -7
View File
@@ -13,8 +13,8 @@ import (
)
// GetRefs returns all references of the repository.
func (repo *Repository) GetRefs() ([]*Reference, error) {
return repo.GetRefsFiltered("")
func (repo *Repository) GetRefs(ctx context.Context) ([]*Reference, error) {
return repo.GetRefsFiltered(ctx, "")
}
// ListOccurrences lists all refs of the given refType the given commit appears in sorted by creation date DESC
@@ -72,19 +72,19 @@ func parseTags(refs []string) []string {
// * "refs/tags/1234567890" vs commit "1234567890"
// In most cases, it SHOULD AVOID using this function, unless there is an irresistible reason (eg: make API friendly to end users)
// If the function is used, the caller SHOULD CHECK the ref type carefully.
func (repo *Repository) UnstableGuessRefByShortName(shortName string) RefName {
if repo.IsBranchExist(shortName) {
func (repo *Repository) UnstableGuessRefByShortName(ctx context.Context, shortName string) RefName {
if repo.IsBranchExist(ctx, shortName) {
return RefNameFromBranch(shortName)
}
if repo.IsTagExist(shortName) {
if repo.IsTagExist(ctx, shortName) {
return RefNameFromTag(shortName)
}
if strings.HasPrefix(shortName, "refs/") {
if repo.IsReferenceExist(shortName) {
if repo.IsReferenceExist(ctx, shortName) {
return RefName(shortName)
}
}
commit, err := repo.GetCommit(shortName)
commit, err := repo.GetCommit(ctx, shortName)
if err == nil {
commitIDString := commit.ID.String()
// make sure the "shortName" is either partial commit ID, or it is HEAD