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

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


The following commit(s) were added to refs/heads/main by this push:
     new 0637366ed59 Fix GitDagBundle to support https (include 46073/46179) 
(#46226)
0637366ed59 is described below

commit 0637366ed59433e6d0ba732fb78464628c0ebe8a
Author: jj.lee <[email protected]>
AuthorDate: Thu Jan 30 13:16:16 2025 +0900

    Fix GitDagBundle to support https (include 46073/46179) (#46226)
---
 airflow/config_templates/config.yml      | 1 -
 airflow/dag_processing/bundles/git.py    | 8 ++++++--
 tests/dag_processing/test_dag_bundles.py | 7 ++++++-
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/airflow/config_templates/config.yml 
b/airflow/config_templates/config.yml
index 9afff334518..cd800cb98e5 100644
--- a/airflow/config_templates/config.yml
+++ b/airflow/config_templates/config.yml
@@ -2615,7 +2615,6 @@ dag_processor:
                 "classpath": "airflow.dag_processing.bundles.git.GitDagBundle",
                 "kwargs": {
                     "subdir": "dags",
-                    "repo_url": "[email protected]:example.com/my-dags.git",
                     "tracking_ref": "main",
                     "refresh_interval": 0
             }
diff --git a/airflow/dag_processing/bundles/git.py 
b/airflow/dag_processing/bundles/git.py
index 944c3b4b6ba..fb478baa536 100644
--- a/airflow/dag_processing/bundles/git.py
+++ b/airflow/dag_processing/bundles/git.py
@@ -140,9 +140,11 @@ class GitDagBundle(BaseDagBundle, LoggingMixin):
             raise AirflowException(f"Connection {self.git_conn_id} doesn't 
have a host url")
         if isinstance(self.repo_url, os.PathLike):
             self._initialize()
-        elif not self.repo_url.startswith("git@") or not 
self.repo_url.endswith(".git"):
+        elif not (
+            self.repo_url.startswith("git@") or 
self.repo_url.startswith("https")
+        ) or not self.repo_url.endswith(".git"):
             raise AirflowException(
-                f"Invalid git URL: {self.repo_url}. URL must start with git@ 
and end with .git"
+                f"Invalid git URL: {self.repo_url}. URL must start with git@ 
or https and end with .git"
             )
         else:
             self._initialize()
@@ -236,6 +238,8 @@ class GitDagBundle(BaseDagBundle, LoggingMixin):
             return None
         if url.startswith("git@"):
             url = self._convert_git_ssh_url_to_https(url)
+        if url.endswith(".git"):
+            url = url[:-4]
         parsed_url = urlparse(url)
         host = parsed_url.hostname
         if not host:
diff --git a/tests/dag_processing/test_dag_bundles.py 
b/tests/dag_processing/test_dag_bundles.py
index 63572bb5eb6..331a215df7d 100644
--- a/tests/dag_processing/test_dag_bundles.py
+++ b/tests/dag_processing/test_dag_bundles.py
@@ -399,7 +399,8 @@ class TestGitDagBundle:
             tracking_ref=GIT_DEFAULT_BRANCH,
         )
         with pytest.raises(
-            AirflowException, match=f"Invalid git URL: {repo_url}. URL must 
start with git@ and end with .git"
+            AirflowException,
+            match=f"Invalid git URL: {repo_url}. URL must start with git@ or 
https and end with .git",
         ):
             bundle.initialize()
 
@@ -413,6 +414,10 @@ class TestGitDagBundle:
                 "[email protected]:apache/airflow.git",
                 "https://myorg.github.com/apache/airflow/tree/0f0f0f";,
             ),
+            (
+                "https://myorg.github.com/apache/airflow.git";,
+                "https://myorg.github.com/apache/airflow/tree/0f0f0f";,
+            ),
         ],
     )
     @mock.patch("airflow.dag_processing.bundles.git.Repo")

Reply via email to