Skip to content

Commit

Permalink
#840: fixed fetch determine remotes (#841)
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-vcapgemini authored Dec 5, 2024
1 parent e849467 commit 387b579
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions cli/src/main/java/com/devonfw/tools/ide/git/GitContextImpl.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package com.devonfw.tools.ide.git;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.process.ProcessContext;
import com.devonfw.tools.ide.process.ProcessErrorHandling;
import com.devonfw.tools.ide.process.ProcessMode;
import com.devonfw.tools.ide.process.ProcessResult;
import com.devonfw.tools.ide.variable.IdeVariables;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
* Implements the {@link GitContext}.
*/
Expand Down Expand Up @@ -89,8 +89,8 @@ public void pullOrClone(GitUrl gitUrl, Path repository) {
/**
* Handles errors which occurred during git pull.
*
* @param targetRepository the {@link Path} to the target folder where the git repository should be cloned or pulled. It is not the parent directory where git
* will by default create a sub-folder by default on clone but the * final folder that will contain the ".git" subfolder.
* @param targetRepository the {@link Path} to the target folder where the git repository should be cloned or pulled. It is not the parent directory where
* git will by default create a sub-folder by default on clone but the * final folder that will contain the ".git" subfolder.
* @param result the {@link ProcessResult} to evaluate.
*/
private void handleErrors(Path targetRepository, ProcessResult result) {
Expand Down Expand Up @@ -165,7 +165,9 @@ public void fetch(Path repository, String remote, String branch) {
if (remote == null) {
remote = determineRemote(repository);
}
ProcessResult result = runGitCommand(repository, ProcessMode.DEFAULT_CAPTURE, "fetch", remote, branch);

ProcessResult result = runGitCommand(repository, ProcessMode.DEFAULT_CAPTURE, "fetch", Objects.requireNonNullElse(remote, "origin"), branch);

if (!result.isSuccessful()) {
this.context.warning("Git fetch for '{}/{} failed.'.", remote, branch);
}
Expand Down

0 comments on commit 387b579

Please sign in to comment.