@@ -18,6 +18,7 @@ package trigger
18
18
19
19
import (
20
20
"fmt"
21
+ "sigs.k8s.io/prow/pkg/git/v2"
21
22
22
23
"github.com/sirupsen/logrus"
23
24
"sigs.k8s.io/prow/pkg/kube"
@@ -126,12 +127,12 @@ func handleGenericComment(c Client, trigger plugins.Trigger, gc github.GenericCo
126
127
return err
127
128
}
128
129
129
- toTest , err := FilterPresubmits (HonorOkToTest (trigger ), c .GitHubClient , gc .Body , pr , presubmits , c .Logger )
130
+ toTest , err := FilterPresubmits (HonorOkToTest (trigger ), c .GitClient , c . GitHubClient , gc .Body , pr , presubmits , c .Logger )
130
131
if err != nil {
131
132
return err
132
133
}
133
134
if needsHelp , note := pjutil .ShouldRespondWithHelp (gc .Body , len (toTest )); needsHelp {
134
- return addHelpComment (c .GitHubClient , gc .Body , org , repo , pr . Base . Ref , pr . Number , presubmits , gc .HTMLURL , commentAuthor , note , c .Logger )
135
+ return addHelpComment (c .GitClient , c . GitHubClient , gc .Body , org , repo , pr , presubmits , gc .HTMLURL , commentAuthor , note , c .Logger )
135
136
}
136
137
// we want to be able to track re-tests separately from the general body of tests
137
138
additionalLabels := map [string ]string {}
@@ -195,7 +196,7 @@ type GitHubClient interface {
195
196
// If a comment that we get matches more than one of the above patterns, we
196
197
// consider the set of matching presubmits the union of the results from the
197
198
// matching cases.
198
- func FilterPresubmits (honorOkToTest bool , gitHubClient GitHubClient , body string , pr * github.PullRequest , presubmits []config.Presubmit , logger * logrus.Entry ) ([]config.Presubmit , error ) {
199
+ func FilterPresubmits (honorOkToTest bool , gc git. ClientFactory , gitHubClient GitHubClient , body string , pr * github.PullRequest , presubmits []config.Presubmit , logger * logrus.Entry ) ([]config.Presubmit , error ) {
199
200
org , repo , sha := pr .Base .Repo .Owner .Login , pr .Base .Repo .Name , pr .Head .SHA
200
201
201
202
contextGetter := func () (sets.Set [string ], sets.Set [string ], error ) {
@@ -212,8 +213,8 @@ func FilterPresubmits(honorOkToTest bool, gitHubClient GitHubClient, body string
212
213
return nil , err
213
214
}
214
215
215
- number , branch := pr .Number , pr .Base .Ref
216
- changes := config .NewGitHubDeferredChangedFilesProvider (gitHubClient , org , repo , number )
216
+ number , branch , baseSHA , headSHA := pr .Number , pr .Base .Ref , pr . Base . SHA , pr . Head . SHA
217
+ changes := config .NewGitHubDeferredChangedFilesProvider (gc , gitHubClient , org , repo , number , baseSHA , headSHA )
217
218
return pjutil .FilterPresubmits (filter , changes , branch , presubmits , logger )
218
219
}
219
220
@@ -231,8 +232,9 @@ func getContexts(combinedStatus *github.CombinedStatus) (sets.Set[string], sets.
231
232
return failedContexts , allContexts
232
233
}
233
234
234
- func addHelpComment (githubClient githubClient , body , org , repo , branch string , number int , presubmits []config.Presubmit , HTMLURL , user , note string , logger * logrus.Entry ) error {
235
- changes := config .NewGitHubDeferredChangedFilesProvider (githubClient , org , repo , number )
235
+ func addHelpComment (gc git.ClientFactory , githubClient githubClient , body , org , repo string , pr * github.PullRequest , presubmits []config.Presubmit , HTMLURL , user , note string , logger * logrus.Entry ) error {
236
+ number , branch , baseSHA , headSHA := pr .Number , pr .Base .Ref , pr .Base .SHA , pr .Head .SHA
237
+ changes := config .NewGitHubDeferredChangedFilesProvider (gc , githubClient , org , repo , number , baseSHA , headSHA )
236
238
testAllNames , optionalJobsCommands , requiredJobsCommands , err := pjutil .AvailablePresubmits (changes , branch , presubmits , logger )
237
239
if err != nil {
238
240
return err
0 commit comments