You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2023/10/03 14:36:23 UTC

[camel] branch CAMEL-19940/create-working-directory-on-init updated (3b99222e4e9 -> 522dae28b39)

This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a change to branch CAMEL-19940/create-working-directory-on-init
in repository https://gitbox.apache.org/repos/asf/camel.git


 discard 3b99222e4e9 CAMEL-19940: camel-jbang - Create working directory on init
     new 522dae28b39 CAMEL-19940: camel-jbang - Create working directory on init

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (3b99222e4e9)
            \
             N -- N -- N   refs/heads/CAMEL-19940/create-working-directory-on-init (522dae28b39)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../src/main/java/org/apache/camel/dsl/jbang/core/commands/Init.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


[camel] 01/01: CAMEL-19940: camel-jbang - Create working directory on init

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch CAMEL-19940/create-working-directory-on-init
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 522dae28b39fd83a690190599500fccfc6c6d417
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Tue Oct 3 16:33:40 2023 +0200

    CAMEL-19940: camel-jbang - Create working directory on init
---
 .../org/apache/camel/dsl/jbang/core/commands/Init.java | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Init.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Init.java
index 47230fd0433..dee1858505c 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Init.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Init.java
@@ -38,6 +38,7 @@ import picocli.CommandLine.Command;
 import picocli.CommandLine.Option;
 import picocli.CommandLine.Parameters;
 
+import static org.apache.camel.dsl.jbang.core.commands.Run.WORK_DIR;
 import static org.apache.camel.dsl.jbang.core.common.GistHelper.fetchGistUrls;
 import static org.apache.camel.dsl.jbang.core.common.GitHubHelper.asGithubSingleUrl;
 import static org.apache.camel.dsl.jbang.core.common.GitHubHelper.fetchGithubUrls;
@@ -74,6 +75,16 @@ public class Init extends CamelCommand {
 
     @Override
     public Integer doCall() throws Exception {
+        int code = execute();
+        if (code == 0) {
+            // In case of successful execution, we create the working directory if it does not exist to help the tooling
+            // know that it is a Camel JBang project
+            createWorkingDirectoryIfAbsent();
+        }
+        return code;
+    }
+
+    private int execute() throws Exception {
         // is the file referring to an existing file on github/gist
         // then we should download the file to local for use
         if (file.startsWith("https://github.com/")) {
@@ -158,6 +169,13 @@ public class Init extends CamelCommand {
         return 0;
     }
 
+    private void createWorkingDirectoryIfAbsent() {
+        File work = new File(WORK_DIR);
+        if (!work.exists()) {
+            work.mkdirs();
+        }
+    }
+
     private int downloadFromGithub() throws Exception {
         StringJoiner all = new StringJoiner(",");