@@ -44,12 +44,12 @@ func IsWorkflow(path string) bool {
4444 return strings .HasPrefix (path , ".gitea/workflows" ) || strings .HasPrefix (path , ".github/workflows" )
4545}
4646
47- func ListWorkflows (commit * git.Commit ) (string , git.Entries , error ) {
47+ func ListWorkflows (tree * git.Tree ) (string , git.Entries , error ) {
4848 rpath := ".gitea/workflows"
49- tree , err := commit .SubTree (rpath )
49+ tree , err := tree .SubTree (rpath )
5050 if _ , ok := err .(git.ErrNotExist ); ok {
5151 rpath = ".github/workflows"
52- tree , err = commit .SubTree (rpath )
52+ tree , err = tree .SubTree (rpath )
5353 }
5454 if _ , ok := err .(git.ErrNotExist ); ok {
5555 return "" , nil , nil
@@ -105,7 +105,7 @@ func DetectWorkflows(
105105 payload api.Payloader ,
106106 detectSchedule bool ,
107107) ([]* DetectedWorkflow , []* DetectedWorkflow , error ) {
108- _ , entries , err := ListWorkflows (commit )
108+ _ , entries , err := ListWorkflows (git . NewTree ( gitRepo , commit . TreeID ) )
109109 if err != nil {
110110 return nil , nil , err
111111 }
@@ -150,7 +150,7 @@ func DetectWorkflows(
150150}
151151
152152func DetectScheduledWorkflows (gitRepo * git.Repository , commit * git.Commit ) ([]* DetectedWorkflow , error ) {
153- _ , entries , err := ListWorkflows (commit )
153+ _ , entries , err := ListWorkflows (git . NewTree ( gitRepo , commit . TreeID ) )
154154 if err != nil {
155155 return nil , err
156156 }
@@ -204,7 +204,7 @@ func detectMatched(gitRepo *git.Repository, commit *git.Commit, triggedEvent web
204204
205205 case // push
206206 webhook_module .HookEventPush :
207- return matchPushEvent (commit , payload .(* api.PushPayload ), evt )
207+ return matchPushEvent (gitRepo , commit , payload .(* api.PushPayload ), evt )
208208
209209 case // issues
210210 webhook_module .HookEventIssues ,
@@ -256,7 +256,7 @@ func detectMatched(gitRepo *git.Repository, commit *git.Commit, triggedEvent web
256256 }
257257}
258258
259- func matchPushEvent (commit * git.Commit , pushPayload * api.PushPayload , evt * jobparser.Event ) bool {
259+ func matchPushEvent (gitRepo * git. Repository , commit * git.Commit , pushPayload * api.PushPayload , evt * jobparser.Event ) bool {
260260 // with no special filter parameters
261261 if len (evt .Acts ()) == 0 {
262262 return true
@@ -322,7 +322,7 @@ func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobpa
322322 matchTimes ++
323323 break
324324 }
325- filesChanged , err := commit . GetFilesChangedSinceCommit (pushPayload .Before )
325+ filesChanged , err := gitRepo . GetFilesChangedBetween (pushPayload .Before , commit . ID . String () )
326326 if err != nil {
327327 log .Error ("GetFilesChangedSinceCommit [commit_sha1: %s]: %v" , commit .ID .String (), err )
328328 } else {
@@ -339,7 +339,7 @@ func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobpa
339339 matchTimes ++
340340 break
341341 }
342- filesChanged , err := commit . GetFilesChangedSinceCommit (pushPayload .Before )
342+ filesChanged , err := gitRepo . GetFilesChangedBetween (pushPayload .Before , commit . ID . String () )
343343 if err != nil {
344344 log .Error ("GetFilesChangedSinceCommit [commit_sha1: %s]: %v" , commit .ID .String (), err )
345345 } else {
@@ -478,7 +478,7 @@ func matchPullRequestEvent(gitRepo *git.Repository, commit *git.Commit, prPayloa
478478 matchTimes ++
479479 }
480480 case "paths" :
481- filesChanged , err := headCommit . GetFilesChangedSinceCommit (prPayload .PullRequest .MergeBase )
481+ filesChanged , err := gitRepo . GetFilesChangedBetween (prPayload .PullRequest .MergeBase , headCommit . ID . String () )
482482 if err != nil {
483483 log .Error ("GetFilesChangedSinceCommit [commit_sha1: %s]: %v" , headCommit .ID .String (), err )
484484 } else {
@@ -491,7 +491,7 @@ func matchPullRequestEvent(gitRepo *git.Repository, commit *git.Commit, prPayloa
491491 }
492492 }
493493 case "paths-ignore" :
494- filesChanged , err := headCommit . GetFilesChangedSinceCommit (prPayload .PullRequest .MergeBase )
494+ filesChanged , err := gitRepo . GetFilesChangedBetween (prPayload .PullRequest .MergeBase , headCommit . ID . String () )
495495 if err != nil {
496496 log .Error ("GetFilesChangedSinceCommit [commit_sha1: %s]: %v" , headCommit .ID .String (), err )
497497 } else {
0 commit comments