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 2021/12/02 15:05:38 UTC
[camel] branch main updated: camel-jbang - Run files directly from github https urls
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 5f250b8 camel-jbang - Run files directly from github https urls
5f250b8 is described below
commit 5f250b817017f32c646bf9fb364be26eabdc41d3
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Dec 2 16:04:51 2021 +0100
camel-jbang - Run files directly from github https urls
---
.../org/apache/camel/dsl/jbang/core/commands/Run.java | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
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 b5d1403..68da4c3 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
@@ -173,7 +173,6 @@ class Run implements Callable<Integer> {
}
// Camel DSL files
-
if (!ResourceHelper.hasScheme(file) && !file.startsWith("github:")) {
file = "file:" + file;
}
@@ -186,6 +185,11 @@ class Run implements Callable<Integer> {
}
}
+ // automatic map github https urls to github resolver
+ if (file.startsWith("https://github.com/")) {
+ file = mapGithubUrl(file);
+ }
+
js.add(file);
if (reload && file.startsWith("file:")) {
// we can only reload if file based
@@ -239,4 +243,16 @@ class Run implements Callable<Integer> {
return lockFile;
}
+
+ private static String mapGithubUrl(String url) {
+ // strip https://github.com/
+ url = url.substring(19);
+ // https://github.com/apache/camel-k/blob/main/examples/languages/routes.kts
+ // https://github.com/apache/camel-k/blob/v1.7.0/examples/languages/routes.kts
+ url = url.replaceFirst("/", ":");
+ url = url.replaceFirst("/", ":");
+ url = url.replaceFirst("blob/", "");
+ url = url.replaceFirst("/", ":");
+ return "github:" + url;
+ }
}