@@ -71,7 +71,7 @@ void verifyDependencies(String branch, String orgRepository) {
71
71
log .info ("Fetching all dependencies before dependabot..." );
72
72
Set <Dependency > dependenciesBeforeDependabot = micrometerOnly (gradleParser .fetchAllDependencies ());
73
73
Status status = dependabotUpdateStatus (clonedRepo , orgRepository );
74
- pullTheLatestRepoChanges ();
74
+ pullTheLatestRepoChanges (clonedRepo );
75
75
Set <Dependency > dependenciesAfterDependabot = micrometerOnly (gradleParser .fetchAllDependencies ());
76
76
Set <Dependency > diff = new HashSet <>(dependenciesAfterDependabot );
77
77
diff .removeAll (dependenciesBeforeDependabot );
@@ -111,7 +111,7 @@ private Status dependabotUpdateStatus(File clonedRepo, String orgRepository) {
111
111
}
112
112
113
113
private GradleParser getGradleParser (File branch ) {
114
- ProcessRunner branchProcessRunner = new ProcessRunner (null , branch );
114
+ ProcessRunner branchProcessRunner = new ProcessRunner (branch );
115
115
return gradleParser (branchProcessRunner );
116
116
}
117
117
@@ -130,9 +130,9 @@ File clonedDir(String branch) {
130
130
return new File (branch );
131
131
}
132
132
133
- private void pullTheLatestRepoChanges () {
133
+ private void pullTheLatestRepoChanges (File clonedRepo ) {
134
134
log .info ("Pulling the latest repo changes" );
135
- processRunner .run ("git" , "pull" );
135
+ processRunnerForBranch ( clonedRepo ) .run ("git" , "pull" );
136
136
}
137
137
138
138
private void sleep (int timeoutToSleep ) {
@@ -180,12 +180,13 @@ private void triggerDependabotCheck(File clonedRepo) {
180
180
log .info ("Added trigger comment to dependabot.yml" );
181
181
}
182
182
Files .writeString (path , fileContent );
183
- processRunner .run ("git" , "config" , "user.name" , "GitHub Action" );
184
- processRunner .
run (
"git" ,
"config" ,
"user.email" ,
"[email protected] " );
185
- processRunner .run ("git" , "add" , filePath );
186
- processRunner .run ("git" , "commit" , "-m" ,
183
+ ProcessRunner branchProcessRunner = processRunnerForBranch (clonedRepo );
184
+ branchProcessRunner .run ("git" , "config" , "user.name" , "GitHub Action" );
185
+ branchProcessRunner .
run (
"git" ,
"config" ,
"user.email" ,
"[email protected] " );
186
+ branchProcessRunner .run ("git" , "add" , filePath );
187
+ branchProcessRunner .run ("git" , "commit" , "-m" ,
187
188
"ci: " + (hasComment ? "Remove" : "Add" ) + " dependabot trigger comment" );
188
- processRunner .run ("git" , "push" );
189
+ branchProcessRunner .run ("git" , "push" );
189
190
}
190
191
catch (Exception e ) {
191
192
log .error ("Failed to modify dependabot.yml" , e );
@@ -194,6 +195,10 @@ private void triggerDependabotCheck(File clonedRepo) {
194
195
log .info ("Triggered Dependabot check" );
195
196
}
196
197
198
+ ProcessRunner processRunnerForBranch (File clonedRepo ) {
199
+ return new ProcessRunner (this .processRunner , clonedRepo );
200
+ }
201
+
197
202
private void waitForDependabotJobsToFinish (String orgRepository , String githubServerTime ) {
198
203
log .info ("Waiting {} {} for Dependabot jobs to be created..." , initialWait , timeUnit );
199
204
sleep (initialWait );
0 commit comments