26
26
public class GitContextImpl implements GitContext {
27
27
private static final Duration GIT_PULL_CACHE_DELAY_MILLIS = Duration .ofMillis (30 * 60 * 1000 );
28
28
29
- ;
30
-
31
29
private final IdeContext context ;
32
30
33
31
private final ProcessContext processContext ;
34
32
33
+ private final ProcessMode PROCESS_MODE = ProcessMode .DEFAULT ;
34
+
35
35
/**
36
36
* @param context the {@link IdeContext context}.
37
37
*/
@@ -104,7 +104,7 @@ public void pullOrClone(String gitRepoUrl, String branch, Path targetRepository)
104
104
105
105
if (Files .isDirectory (targetRepository .resolve (".git" ))) {
106
106
// checks for remotes
107
- ProcessResult result = this .processContext .addArg ("remote" ).run (ProcessMode . DEFAULT_CAPTURE );
107
+ ProcessResult result = this .processContext .addArg ("remote" ).run (PROCESS_MODE );
108
108
List <String > remotes = result .getOut ();
109
109
if (remotes .isEmpty ()) {
110
110
String message = targetRepository
@@ -166,14 +166,14 @@ public void clone(GitUrl gitRepoUrl, Path targetRepository) {
166
166
this .processContext .addArg ("-q" );
167
167
}
168
168
this .processContext .addArgs ("--recursive" , gitRepoUrl .url (), "--config" , "core.autocrlf=false" , "." );
169
- result = this .processContext .run (ProcessMode . DEFAULT_CAPTURE );
169
+ result = this .processContext .run (PROCESS_MODE );
170
170
if (!result .isSuccessful ()) {
171
171
this .context .warning ("Git failed to clone {} into {}." , parsedUrl , targetRepository );
172
172
}
173
173
String branch = gitRepoUrl .branch ();
174
174
if (branch != null ) {
175
175
this .processContext .addArgs ("checkout" , branch );
176
- result = this .processContext .run (ProcessMode . DEFAULT_CAPTURE );
176
+ result = this .processContext .run (PROCESS_MODE );
177
177
if (!result .isSuccessful ()) {
178
178
this .context .warning ("Git failed to checkout to branch {}" , branch );
179
179
}
@@ -189,7 +189,7 @@ public void pull(Path targetRepository) {
189
189
this .processContext .directory (targetRepository );
190
190
ProcessResult result ;
191
191
// pull from remote
192
- result = this .processContext .addArg ("--no-pager" ).addArg ("pull" ).run (ProcessMode . DEFAULT_CAPTURE );
192
+ result = this .processContext .addArg ("--no-pager" ).addArg ("pull" ).run (PROCESS_MODE );
193
193
194
194
if (!result .isSuccessful ()) {
195
195
Map <String , String > remoteAndBranchName = retrieveRemoteAndBranchName ();
@@ -202,7 +202,7 @@ public void pull(Path targetRepository) {
202
202
private Map <String , String > retrieveRemoteAndBranchName () {
203
203
204
204
Map <String , String > remoteAndBranchName = new HashMap <>();
205
- ProcessResult remoteResult = this .processContext .addArg ("branch" ).addArg ("-vv" ).run (ProcessMode . DEFAULT_CAPTURE );
205
+ ProcessResult remoteResult = this .processContext .addArg ("branch" ).addArg ("-vv" ).run (PROCESS_MODE );
206
206
List <String > remotes = remoteResult .getOut ();
207
207
if (!remotes .isEmpty ()) {
208
208
for (String remote : remotes ) {
@@ -233,14 +233,14 @@ public void reset(Path targetRepository, String remoteName, String branchName) {
233
233
this .processContext .directory (targetRepository );
234
234
ProcessResult result ;
235
235
// check for changed files
236
- result = this .processContext .addArg ("diff-index" ).addArg ("--quiet" ).addArg ("HEAD" ).run (ProcessMode . DEFAULT_CAPTURE );
236
+ result = this .processContext .addArg ("diff-index" ).addArg ("--quiet" ).addArg ("HEAD" ).run (PROCESS_MODE );
237
237
238
238
if (!result .isSuccessful ()) {
239
239
// reset to origin/master
240
240
context .warning ("Git has detected modified files -- attempting to reset {} to '{}/{}'." , targetRepository ,
241
241
remoteName , branchName );
242
242
result = this .processContext .addArg ("reset" ).addArg ("--hard" ).addArg (remoteName + "/" + branchName )
243
- .run (ProcessMode . DEFAULT_CAPTURE );
243
+ .run (PROCESS_MODE );
244
244
245
245
if (!result .isSuccessful ()) {
246
246
context .warning ("Git failed to reset {} to '{}/{}'." , remoteName , branchName , targetRepository );
@@ -256,12 +256,12 @@ public void cleanup(Path targetRepository) {
256
256
ProcessResult result ;
257
257
// check for untracked files
258
258
result = this .processContext .addArg ("ls-files" ).addArg ("--other" ).addArg ("--directory" ).addArg ("--exclude-standard" )
259
- .run (ProcessMode . DEFAULT_CAPTURE );
259
+ .run (PROCESS_MODE );
260
260
261
261
if (!result .getOut ().isEmpty ()) {
262
262
// delete untracked files
263
263
context .warning ("Git detected untracked files in {} and is attempting a cleanup." , targetRepository );
264
- result = this .processContext .addArg ("clean" ).addArg ("-df" ).run (ProcessMode . DEFAULT_CAPTURE );
264
+ result = this .processContext .addArg ("clean" ).addArg ("-df" ).run (PROCESS_MODE );
265
265
266
266
if (!result .isSuccessful ()) {
267
267
context .warning ("Git failed to clean the repository {}." , targetRepository );
0 commit comments