You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/05/09 12:08:32 UTC

[camel] branch main updated: CAMEL-18084: camel-jbang - Run from gist/git should work also if its a kamelet

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

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 0ab808910e6 CAMEL-18084: camel-jbang - Run from gist/git should work also if its a kamelet
0ab808910e6 is described below

commit 0ab808910e6356a07c1309edb6886ccfaa6a87e2
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon May 9 14:08:07 2022 +0200

    CAMEL-18084: camel-jbang - Run from gist/git should work also if its a kamelet
---
 .../apache/camel/dsl/jbang/core/commands/Run.java  | 28 ++++++++++++----------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
index 884538bcc85..497dd2a166e 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
@@ -425,10 +425,14 @@ class Run implements Callable<Integer> {
                 // automatic map github https urls to github resolver
                 if (file.startsWith("https://github.com/")) {
                     file = evalGithubSource(main, file);
-                }
-
-                if (file.startsWith("https://gist.github.com/")) {
+                    if (file == null) {
+                        continue; // all mapped continue to next
+                    }
+                } else if (file.startsWith("https://gist.github.com/")) {
                     file = evalGistSource(main, file);
+                    if (file == null) {
+                        continue; // all mapped continue to next
+                    }
                 }
 
                 js.add(file);
@@ -513,9 +517,6 @@ class Run implements Callable<Integer> {
         StringJoiner properties = new StringJoiner(",");
         fetchGistUrls(file, routes, kamelets, properties);
 
-        if (routes.length() > 0) {
-            file = routes.toString();
-        }
         if (properties.length() > 0) {
             main.addInitialProperty("camel.component.properties.location", properties.toString());
         }
@@ -529,7 +530,10 @@ class Run implements Callable<Integer> {
             }
             main.addInitialProperty("camel.component.kamelet.location", loc);
         }
-        return file;
+        if (routes.length() > 0) {
+            return routes.toString();
+        }
+        return null;
     }
 
     private String evalGithubSource(KameletMain main, String file) throws Exception {
@@ -537,16 +541,13 @@ class Run implements Callable<Integer> {
         boolean wildcard = FileUtil.onlyName(file, false).contains("*");
         if (ext != null && !wildcard) {
             // it is a single file so map to
-            file = asGithubSingleUrl(file);
+            return asGithubSingleUrl(file);
         } else {
             StringJoiner routes = new StringJoiner(",");
             StringJoiner kamelets = new StringJoiner(",");
             StringJoiner properties = new StringJoiner(",");
             fetchGithubUrls(file, routes, kamelets, properties);
 
-            if (routes.length() > 0) {
-                file = routes.toString();
-            }
             if (properties.length() > 0) {
                 main.addInitialProperty("camel.component.properties.location", properties.toString());
             }
@@ -560,8 +561,11 @@ class Run implements Callable<Integer> {
                 }
                 main.addInitialProperty("camel.component.kamelet.location", loc);
             }
+            if (routes.length() > 0) {
+                return routes.toString();
+            }
+            return null;
         }
-        return file;
     }
 
     private String loadFromClipboard(String file) throws UnsupportedFlavorException, IOException {