mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-03 02:09:39 +00:00
refactor: remove Ctx field from git.Repository (#38500)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user