@@ -6,6 +6,7 @@ package actions
66import (
77 "fmt"
88 "net/http"
9+ "net/url"
910 "path"
1011 "strings"
1112
@@ -29,9 +30,9 @@ import (
2930
3031func getActionWorkflowPath (commit * git.Commit ) string {
3132 paths := []string {".gitea/workflows" , ".github/workflows" }
32- for _ , path := range paths {
33- if _ , err := commit .SubTree (path ); err == nil {
34- return path
33+ for _ , treePath := range paths {
34+ if _ , err := commit .SubTree (treePath ); err == nil {
35+ return treePath
3536 }
3637 }
3738 return ""
@@ -43,9 +44,9 @@ func getActionWorkflowEntry(ctx *context.APIContext, commit *git.Commit, folder
4344
4445 defaultBranch , _ := commit .GetBranchName ()
4546
46- URL := fmt .Sprintf ("%s/actions/workflows/%s" , ctx .Repo .Repository .APIURL (), entry .Name ())
47- HTMLURL := fmt .Sprintf ("%s/src/branch/%s/%s/%s" , ctx .Repo .Repository .HTMLURL (ctx ), defaultBranch , folder , entry .Name ())
48- badgeURL := fmt .Sprintf ("%s/actions/workflows/%s/badge.svg?branch=%s" , ctx .Repo .Repository .HTMLURL (ctx ), entry .Name (), ctx .Repo .Repository .DefaultBranch )
47+ workflowURL := fmt .Sprintf ("%s/actions/workflows/%s" , ctx .Repo .Repository .APIURL (), url . PathEscape ( entry .Name () ))
48+ workflowRepoURL := fmt .Sprintf ("%s/src/branch/%s/%s/%s" , ctx .Repo .Repository .HTMLURL (ctx ), util . PathEscapeSegments ( defaultBranch ), util . PathEscapeSegments ( folder ), url . PathEscape ( entry .Name () ))
49+ badgeURL := fmt .Sprintf ("%s/actions/workflows/%s/badge.svg?branch=%s" , ctx .Repo .Repository .HTMLURL (ctx ), url . PathEscape ( entry .Name ()), url . QueryEscape ( ctx .Repo .Repository .DefaultBranch ) )
4950
5051 // See https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#get-a-workflow
5152 // State types:
@@ -74,8 +75,8 @@ func getActionWorkflowEntry(ctx *context.APIContext, commit *git.Commit, folder
7475 State : state ,
7576 CreatedAt : createdAt ,
7677 UpdatedAt : updatedAt ,
77- URL : URL ,
78- HTMLURL : HTMLURL ,
78+ URL : workflowURL ,
79+ HTMLURL : workflowRepoURL ,
7980 BadgeURL : badgeURL ,
8081 }
8182}
@@ -133,7 +134,7 @@ func GetActionWorkflow(ctx *context.APIContext, workflowID string) (*api.ActionW
133134 }
134135 }
135136
136- return nil , fmt . Errorf ("workflow '%s' not found" , workflowID )
137+ return nil , util . NewNotExistErrorf ("workflow %q not found" , workflowID )
137138}
138139
139140func DisableActionWorkflow (ctx * context.APIContext , workflowID string ) error {
0 commit comments