77 "context"
88 "fmt"
99
10- repo_model "code.gitea.io/gitea/models/repo"
11- "code.gitea.io/gitea/modules/git"
1210 "code.gitea.io/gitea/modules/util"
11+ gitea_ctx "code.gitea.io/gitea/services/context"
1312)
1413
1514type ContainedLinks struct { // TODO: better name?
@@ -24,32 +23,32 @@ type namedLink struct { // TODO: better name?
2423}
2524
2625// LoadBranchesAndTags creates a new repository branch
27- func LoadBranchesAndTags (ctx context.Context , repo * repo_model .Repository , gitRepo * git. Repository , repoLink , commitSHA string ) (* ContainedLinks , error ) {
28- containedTags , err := gitRepo .ListOccurrences (ctx , "tag" , commitSHA )
26+ func LoadBranchesAndTags (ctx context.Context , baseRepo * gitea_ctx .Repository , commitSHA string ) (* ContainedLinks , error ) {
27+ containedTags , err := baseRepo . GitRepo .ListOccurrences (ctx , "tag" , commitSHA )
2928 if err != nil {
3029 return nil , fmt .Errorf ("encountered a problem while querying %s: %w" , "tags" , err )
3130 }
32- containedBranches , err := gitRepo .ListOccurrences (ctx , "branch" , commitSHA )
31+ containedBranches , err := baseRepo . GitRepo .ListOccurrences (ctx , "branch" , commitSHA )
3332 if err != nil {
3433 return nil , fmt .Errorf ("encountered a problem while querying %s: %w" , "branches" , err )
3534 }
3635
3736 result := & ContainedLinks {
38- DefaultBranch : repo .DefaultBranch ,
37+ DefaultBranch : baseRepo . Repository .DefaultBranch ,
3938 Branches : make ([]* namedLink , 0 , len (containedBranches )),
4039 Tags : make ([]* namedLink , 0 , len (containedTags )),
4140 }
4241 for _ , tag := range containedTags {
4342 // TODO: Use a common method to get the link to a branch/tag instead of hard-coding it here
4443 result .Tags = append (result .Tags , & namedLink {
4544 Name : tag ,
46- WebLink : fmt .Sprintf ("%s/src/tag/%s" , repoLink , util .PathEscapeSegments (tag )),
45+ WebLink : fmt .Sprintf ("%s/src/tag/%s" , baseRepo . RepoLink , util .PathEscapeSegments (tag )),
4746 })
4847 }
4948 for _ , branch := range containedBranches {
5049 result .Branches = append (result .Branches , & namedLink {
5150 Name : branch ,
52- WebLink : fmt .Sprintf ("%s/src/branch/%s" , repoLink , util .PathEscapeSegments (branch )),
51+ WebLink : fmt .Sprintf ("%s/src/branch/%s" , baseRepo . RepoLink , util .PathEscapeSegments (branch )),
5352 })
5453 }
5554 return result , nil
0 commit comments