Skip to content

Commit

Permalink
Merge pull request quarkiverse#40 from iocanel/check-remotes
Browse files Browse the repository at this point in the history
Generate commands also check if remote repos are defined
  • Loading branch information
iocanel authored Sep 25, 2024
2 parents 5a25064 + 3d206e0 commit e1a64d1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.concurrent.Callable;
Expand Down Expand Up @@ -48,6 +49,12 @@ public Integer call() {
return ExitCode.USAGE;
}

Map<String, String> remotes = Git.getRemotes(scmRoot.get());
if (remotes.isEmpty()) {
System.out.println("Unable to determine the SCM remotes for the project at " + projectRoot + ". Aborting.");
return ExitCode.USAGE;
}

BuildTool buildTool = QuarkusProjectHelper.detectExistingBuildTool(projectRoot);
if (buildTool == null) {
System.out.println("Unable to determine the build tool used for the project at " + projectRoot);
Expand Down
11 changes: 11 additions & 0 deletions cli/src/main/java/io/quarkiverse/argocd/cli/utils/Git.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Map;
import java.util.Optional;

import org.eclipse.jgit.api.FetchCommand;
Expand Down Expand Up @@ -159,6 +160,16 @@ public static Optional<String> getRemoteName(String url) {
});
}

/**
* Get the git remote urls as a map.
*
* @param path the path to the git config.
* @return A {@link Map} of urls per remote.
*/
public static Map<String, String> getRemotes(Path path) {
return io.dekorate.utils.Git.getRemotes(path);
}

public static Optional<Path> getScmRoot() {
Path dir = Paths.get("").toAbsolutePath();
while (dir != null && !dir.resolve(DOT_GIT).toFile().exists()) {
Expand Down

0 comments on commit e1a64d1

Please sign in to comment.