From 13e2f1e6c4eff0eef2d34cd6eb618a48eb42e72e Mon Sep 17 00:00:00 2001 From: Thiago Ruiz Date: Mon, 2 Sep 2024 17:59:17 -0300 Subject: [PATCH] fix(app): #1347 Fix the usage of karavan.git.repository on git clone Closes: #1347 --- .../java/org/apache/camel/karavan/service/GitService.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/karavan-app/src/main/java/org/apache/camel/karavan/service/GitService.java b/karavan-app/src/main/java/org/apache/camel/karavan/service/GitService.java index 4a92db1480a..b191fab1d43 100644 --- a/karavan-app/src/main/java/org/apache/camel/karavan/service/GitService.java +++ b/karavan-app/src/main/java/org/apache/camel/karavan/service/GitService.java @@ -193,7 +193,7 @@ public Git getGit(boolean checkout, String folder) throws GitAPIException, IOExc git = init(folder, gitConfig.getUri(), gitConfig.getBranch()); } else { try { - git = clone(folder, gitConfig.getUri()); + git = clone(folder, gitConfig.getUri(), gitConfig.getBranch()); var branch = git.branchList().call().stream().filter(ref -> ref.getName().equals("refs/heads/" + gitConfig.getBranch())).findFirst(); if (branch.isEmpty()) { createBranch(git, gitConfig.getBranch()); @@ -332,11 +332,12 @@ public void deleteProject(String projectId, String authorName, String authorEmai } } - private Git clone(String dir, String uri) throws GitAPIException, URISyntaxException { + private Git clone(String dir, String uri, String branch) throws GitAPIException, URISyntaxException { CloneCommand command = Git.cloneRepository(); command.setCloneAllBranches(false); command.setDirectory(Paths.get(dir).toFile()); command.setURI(uri); + command.setBranch(branch); setCredentials(command); Git git = command.call(); addRemote(git, uri); @@ -430,7 +431,7 @@ public boolean checkGit() throws Exception { GitConfig gitConfig = getGitConfig(); String uuid = UUID.randomUUID().toString(); String folder = vertx.fileSystem().createTempDirectoryBlocking(uuid); - try (Git git = clone(folder, gitConfig.getUri())) { + try (Git git = clone(folder, gitConfig.getUri(), gitConfig.getBranch())) { LOGGER.info("Git is ready"); } catch (Exception e) { LOGGER.info("Error connecting git: " + (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()));