Skip to content

Commit 6278317

Browse files
#277: implemented requested changes
moved ProcessMode to constant changed ProcessMode from DEFAULT_CAPTURE to DEFAULT
1 parent 32e0472 commit 6278317

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

cli/src/main/java/com/devonfw/tools/ide/context/GitContextImpl.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
public class GitContextImpl implements GitContext {
2727
private static final Duration GIT_PULL_CACHE_DELAY_MILLIS = Duration.ofMillis(30 * 60 * 1000);
2828

29-
;
30-
3129
private final IdeContext context;
3230

3331
private final ProcessContext processContext;
3432

33+
private final ProcessMode PROCESS_MODE = ProcessMode.DEFAULT;
34+
3535
/**
3636
* @param context the {@link IdeContext context}.
3737
*/
@@ -104,7 +104,7 @@ public void pullOrClone(String gitRepoUrl, String branch, Path targetRepository)
104104

105105
if (Files.isDirectory(targetRepository.resolve(".git"))) {
106106
// checks for remotes
107-
ProcessResult result = this.processContext.addArg("remote").run(ProcessMode.DEFAULT_CAPTURE);
107+
ProcessResult result = this.processContext.addArg("remote").run(PROCESS_MODE);
108108
List<String> remotes = result.getOut();
109109
if (remotes.isEmpty()) {
110110
String message = targetRepository
@@ -166,14 +166,14 @@ public void clone(GitUrl gitRepoUrl, Path targetRepository) {
166166
this.processContext.addArg("-q");
167167
}
168168
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);
170170
if (!result.isSuccessful()) {
171171
this.context.warning("Git failed to clone {} into {}.", parsedUrl, targetRepository);
172172
}
173173
String branch = gitRepoUrl.branch();
174174
if (branch != null) {
175175
this.processContext.addArgs("checkout", branch);
176-
result = this.processContext.run(ProcessMode.DEFAULT_CAPTURE);
176+
result = this.processContext.run(PROCESS_MODE);
177177
if (!result.isSuccessful()) {
178178
this.context.warning("Git failed to checkout to branch {}", branch);
179179
}
@@ -189,7 +189,7 @@ public void pull(Path targetRepository) {
189189
this.processContext.directory(targetRepository);
190190
ProcessResult result;
191191
// 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);
193193

194194
if (!result.isSuccessful()) {
195195
Map<String, String> remoteAndBranchName = retrieveRemoteAndBranchName();
@@ -202,7 +202,7 @@ public void pull(Path targetRepository) {
202202
private Map<String, String> retrieveRemoteAndBranchName() {
203203

204204
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);
206206
List<String> remotes = remoteResult.getOut();
207207
if (!remotes.isEmpty()) {
208208
for (String remote : remotes) {
@@ -233,14 +233,14 @@ public void reset(Path targetRepository, String remoteName, String branchName) {
233233
this.processContext.directory(targetRepository);
234234
ProcessResult result;
235235
// 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);
237237

238238
if (!result.isSuccessful()) {
239239
// reset to origin/master
240240
context.warning("Git has detected modified files -- attempting to reset {} to '{}/{}'.", targetRepository,
241241
remoteName, branchName);
242242
result = this.processContext.addArg("reset").addArg("--hard").addArg(remoteName + "/" + branchName)
243-
.run(ProcessMode.DEFAULT_CAPTURE);
243+
.run(PROCESS_MODE);
244244

245245
if (!result.isSuccessful()) {
246246
context.warning("Git failed to reset {} to '{}/{}'.", remoteName, branchName, targetRepository);
@@ -256,12 +256,12 @@ public void cleanup(Path targetRepository) {
256256
ProcessResult result;
257257
// check for untracked files
258258
result = this.processContext.addArg("ls-files").addArg("--other").addArg("--directory").addArg("--exclude-standard")
259-
.run(ProcessMode.DEFAULT_CAPTURE);
259+
.run(PROCESS_MODE);
260260

261261
if (!result.getOut().isEmpty()) {
262262
// delete untracked files
263263
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);
265265

266266
if (!result.isSuccessful()) {
267267
context.warning("Git failed to clean the repository {}.", targetRepository);

0 commit comments

Comments
 (0)