@@ -44,12 +44,12 @@ func IsWorkflow(path string) bool {
44
44
return strings .HasPrefix (path , ".gitea/workflows" ) || strings .HasPrefix (path , ".github/workflows" )
45
45
}
46
46
47
- func ListWorkflows (commit * git.Commit ) (string , git.Entries , error ) {
47
+ func ListWorkflows (tree * git.Tree ) (string , git.Entries , error ) {
48
48
rpath := ".gitea/workflows"
49
- tree , err := commit .SubTree (rpath )
49
+ tree , err := tree .SubTree (rpath )
50
50
if _ , ok := err .(git.ErrNotExist ); ok {
51
51
rpath = ".github/workflows"
52
- tree , err = commit .SubTree (rpath )
52
+ tree , err = tree .SubTree (rpath )
53
53
}
54
54
if _ , ok := err .(git.ErrNotExist ); ok {
55
55
return "" , nil , nil
@@ -105,7 +105,7 @@ func DetectWorkflows(
105
105
payload api.Payloader ,
106
106
detectSchedule bool ,
107
107
) ([]* DetectedWorkflow , []* DetectedWorkflow , error ) {
108
- _ , entries , err := ListWorkflows (commit )
108
+ _ , entries , err := ListWorkflows (git . NewTree ( gitRepo , commit . TreeID ) )
109
109
if err != nil {
110
110
return nil , nil , err
111
111
}
@@ -150,7 +150,7 @@ func DetectWorkflows(
150
150
}
151
151
152
152
func DetectScheduledWorkflows (gitRepo * git.Repository , commit * git.Commit ) ([]* DetectedWorkflow , error ) {
153
- _ , entries , err := ListWorkflows (commit )
153
+ _ , entries , err := ListWorkflows (git . NewTree ( gitRepo , commit . TreeID ) )
154
154
if err != nil {
155
155
return nil , err
156
156
}
@@ -204,7 +204,7 @@ func detectMatched(gitRepo *git.Repository, commit *git.Commit, triggedEvent web
204
204
205
205
case // push
206
206
webhook_module .HookEventPush :
207
- return matchPushEvent (commit , payload .(* api.PushPayload ), evt )
207
+ return matchPushEvent (gitRepo , commit , payload .(* api.PushPayload ), evt )
208
208
209
209
case // issues
210
210
webhook_module .HookEventIssues ,
@@ -256,7 +256,7 @@ func detectMatched(gitRepo *git.Repository, commit *git.Commit, triggedEvent web
256
256
}
257
257
}
258
258
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 {
260
260
// with no special filter parameters
261
261
if len (evt .Acts ()) == 0 {
262
262
return true
@@ -322,7 +322,7 @@ func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobpa
322
322
matchTimes ++
323
323
break
324
324
}
325
- filesChanged , err := commit . GetFilesChangedSinceCommit (pushPayload .Before )
325
+ filesChanged , err := gitRepo . GetFilesChangedBetween (pushPayload .Before , commit . ID . String () )
326
326
if err != nil {
327
327
log .Error ("GetFilesChangedSinceCommit [commit_sha1: %s]: %v" , commit .ID .String (), err )
328
328
} else {
@@ -339,7 +339,7 @@ func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobpa
339
339
matchTimes ++
340
340
break
341
341
}
342
- filesChanged , err := commit . GetFilesChangedSinceCommit (pushPayload .Before )
342
+ filesChanged , err := gitRepo . GetFilesChangedBetween (pushPayload .Before , commit . ID . String () )
343
343
if err != nil {
344
344
log .Error ("GetFilesChangedSinceCommit [commit_sha1: %s]: %v" , commit .ID .String (), err )
345
345
} else {
@@ -478,7 +478,7 @@ func matchPullRequestEvent(gitRepo *git.Repository, commit *git.Commit, prPayloa
478
478
matchTimes ++
479
479
}
480
480
case "paths" :
481
- filesChanged , err := headCommit . GetFilesChangedSinceCommit (prPayload .PullRequest .MergeBase )
481
+ filesChanged , err := gitRepo . GetFilesChangedBetween (prPayload .PullRequest .MergeBase , headCommit . ID . String () )
482
482
if err != nil {
483
483
log .Error ("GetFilesChangedSinceCommit [commit_sha1: %s]: %v" , headCommit .ID .String (), err )
484
484
} else {
@@ -491,7 +491,7 @@ func matchPullRequestEvent(gitRepo *git.Repository, commit *git.Commit, prPayloa
491
491
}
492
492
}
493
493
case "paths-ignore" :
494
- filesChanged , err := headCommit . GetFilesChangedSinceCommit (prPayload .PullRequest .MergeBase )
494
+ filesChanged , err := gitRepo . GetFilesChangedBetween (prPayload .PullRequest .MergeBase , headCommit . ID . String () )
495
495
if err != nil {
496
496
log .Error ("GetFilesChangedSinceCommit [commit_sha1: %s]: %v" , headCommit .ID .String (), err )
497
497
} else {
0 commit comments