File tree Expand file tree Collapse file tree 1 file changed +17
-14
lines changed Expand file tree Collapse file tree 1 file changed +17
-14
lines changed Original file line number Diff line number Diff line change @@ -21,22 +21,25 @@ func GetWorkflowBadge(ctx *context.Context) {
2121 branch := ctx .Req .URL .Query ().Get ("branch" )
2222 tag := ctx .Req .URL .Query ().Get ("tag" )
2323 useLatestTag := ctx .Req .URL .Query ().Has ("latest_tag" )
24- if branch == "" && tag == "" && ! useLatestTag {
25- branch = ctx .Repo .Repository .DefaultBranch
26- }
27- ref := fmt .Sprintf ("refs/heads/%s" , branch )
28- if branch == "" && tag != "" {
29- if useLatestTag {
30- tags , _ , err := ctx .Repo .GitRepo .GetTagInfos (0 , 1 )
31- if err != nil {
32- ctx .ServerError ("GetTagInfos" , err )
33- return
34- }
35- if len (tags ) != 0 {
36- tag = tags [0 ].Name
37- }
24+ var ref string
25+ switch {
26+ case useLatestTag :
27+ tags , _ , err := ctx .Repo .GitRepo .GetTagInfos (0 , 1 )
28+ if err != nil {
29+ ctx .ServerError ("GetTagInfos" , err )
30+ return
31+ }
32+ if len (tags ) != 0 {
33+ tag = tags [0 ].Name
3834 }
3935 ref = fmt .Sprintf ("refs/tags/%s" , tag )
36+ case tag != "" :
37+ ref = fmt .Sprintf ("refs/tags/%s" , tag )
38+ case branch != "" :
39+ ref = fmt .Sprintf ("refs/heads/%s" , branch )
40+ default :
41+ branch = ctx .Repo .Repository .DefaultBranch
42+ ref = fmt .Sprintf ("refs/heads/%s" , branch )
4043 }
4144 event := ctx .Req .URL .Query ().Get ("event" )
4245
You can’t perform that action at this time.
0 commit comments