apache-airflow-providers-git 0.0.1rc1__tar.gz → 0.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of apache-airflow-providers-git might be problematic. Click here for more details.

Files changed (28) hide show
  1. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/PKG-INFO +7 -7
  2. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/README.rst +3 -3
  3. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/docs/changelog.rst +20 -0
  4. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/docs/commits.rst +18 -1
  5. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/docs/index.rst +1 -1
  6. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/provider.yaml +2 -1
  7. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/pyproject.toml +4 -4
  8. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/src/airflow/providers/git/__init__.py +1 -1
  9. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/src/airflow/providers/git/bundles/git.py +25 -15
  10. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/tests/unit/git/bundles/test_git.py +132 -17
  11. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/docs/bundles/index.rst +0 -0
  12. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/docs/conf.py +0 -0
  13. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/docs/connections/git.rst +0 -0
  14. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/docs/installing-providers-from-sources.rst +0 -0
  15. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/docs/security.rst +0 -0
  16. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/src/airflow/__init__.py +0 -0
  17. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/src/airflow/providers/__init__.py +0 -0
  18. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/src/airflow/providers/git/LICENSE +0 -0
  19. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/src/airflow/providers/git/bundles/__init__.py +0 -0
  20. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/src/airflow/providers/git/get_provider_info.py +0 -0
  21. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/src/airflow/providers/git/hooks/__init__.py +0 -0
  22. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/src/airflow/providers/git/hooks/git.py +0 -0
  23. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/tests/conftest.py +0 -0
  24. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/tests/unit/__init__.py +0 -0
  25. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/tests/unit/git/__init__.py +0 -0
  26. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/tests/unit/git/bundles/__init__.py +0 -0
  27. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/tests/unit/git/hooks/__init__.py +0 -0
  28. {apache_airflow_providers_git-0.0.1rc1 → apache_airflow_providers_git-0.0.2}/tests/unit/git/hooks/test_git.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apache-airflow-providers-git
3
- Version: 0.0.1rc1
3
+ Version: 0.0.2
4
4
  Summary: Provider package apache-airflow-providers-git for Apache Airflow
5
5
  Keywords: airflow-provider,git,airflow,integration
6
6
  Author-email: Apache Software Foundation <dev@airflow.apache.org>
@@ -20,11 +20,11 @@ Classifier: Programming Language :: Python :: 3.10
20
20
  Classifier: Programming Language :: Python :: 3.11
21
21
  Classifier: Programming Language :: Python :: 3.12
22
22
  Classifier: Topic :: System :: Monitoring
23
- Requires-Dist: apache-airflow>=3.0.0rc0
23
+ Requires-Dist: apache-airflow>=3.0.0
24
24
  Requires-Dist: GitPython>=3.1.44
25
25
  Project-URL: Bug Tracker, https://github.com/apache/airflow/issues
26
- Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-git/0.0.1/changelog.html
27
- Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-git/0.0.1
26
+ Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-git/0.0.2/changelog.html
27
+ Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-git/0.0.2
28
28
  Project-URL: Mastodon, https://fosstodon.org/@airflow
29
29
  Project-URL: Slack Chat, https://s.apache.org/airflow-slack
30
30
  Project-URL: Source Code, https://github.com/apache/airflow
@@ -55,7 +55,7 @@ Project-URL: YouTube, https://www.youtube.com/channel/UCSXwxpWZQ7XZ1WL3wqevChA/
55
55
 
56
56
  Package ``apache-airflow-providers-git``
57
57
 
58
- Release: ``0.0.1``
58
+ Release: ``0.0.2``
59
59
 
60
60
 
61
61
  `Distributed version control system (GIT) <https://git-scm.com/>`__
@@ -68,7 +68,7 @@ This is a provider package for ``git`` provider. All classes for this provider p
68
68
  are in ``airflow.providers.git`` python package.
69
69
 
70
70
  You can find package information and changelog for the provider
71
- in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-git/0.0.1/>`_.
71
+ in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-git/0.0.2/>`_.
72
72
 
73
73
  Installation
74
74
  ------------
@@ -90,5 +90,5 @@ PIP package Version required
90
90
  ================== ==================
91
91
 
92
92
  The changelog for the provider package can be found in the
93
- `changelog <https://airflow.apache.org/docs/apache-airflow-providers-git/0.0.1/changelog.html>`_.
93
+ `changelog <https://airflow.apache.org/docs/apache-airflow-providers-git/0.0.2/changelog.html>`_.
94
94
 
@@ -23,7 +23,7 @@
23
23
 
24
24
  Package ``apache-airflow-providers-git``
25
25
 
26
- Release: ``0.0.1``
26
+ Release: ``0.0.2``
27
27
 
28
28
 
29
29
  `Distributed version control system (GIT) <https://git-scm.com/>`__
@@ -36,7 +36,7 @@ This is a provider package for ``git`` provider. All classes for this provider p
36
36
  are in ``airflow.providers.git`` python package.
37
37
 
38
38
  You can find package information and changelog for the provider
39
- in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-git/0.0.1/>`_.
39
+ in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-git/0.0.2/>`_.
40
40
 
41
41
  Installation
42
42
  ------------
@@ -58,4 +58,4 @@ PIP package Version required
58
58
  ================== ==================
59
59
 
60
60
  The changelog for the provider package can be found in the
61
- `changelog <https://airflow.apache.org/docs/apache-airflow-providers-git/0.0.1/changelog.html>`_.
61
+ `changelog <https://airflow.apache.org/docs/apache-airflow-providers-git/0.0.2/changelog.html>`_.
@@ -15,6 +15,26 @@
15
15
  specific language governing permissions and limitations
16
16
  under the License.
17
17
 
18
+ 0.0.2
19
+ .....
20
+
21
+ Bug Fixes
22
+ ~~~~~~~~~
23
+
24
+ * ``Don't log repo_url in git dag bundle (#48909)``
25
+ * ``Make git connection optional for git dag bundle (#49270)``
26
+ * ``Use 'git_default' if the user defines nothing (#49359)``
27
+
28
+ Misc
29
+ ~~~~
30
+
31
+ * ``Include subdir in Gitbundle view url (#49239)``
32
+
33
+ .. Below changes are excluded from the changelog. Move them to
34
+ appropriate section above if needed. Do not delete the lines(!):
35
+ * ``Prepare docs for Apr 3rd wave of providers (#49338)``
36
+ * ``Update documentation for edge3 and git provider (#49365)``
37
+
18
38
  0.0.1
19
39
  .....
20
40
 
@@ -34,14 +34,31 @@ For high-level changelog, see :doc:`package information including changelog <ind
34
34
 
35
35
 
36
36
 
37
+ 0.0.2
38
+ .....
39
+
40
+ Latest change: 2025-04-16
41
+
42
+ ================================================================================================== =========== ============================================================
43
+ Commit Committed Subject
44
+ ================================================================================================== =========== ============================================================
45
+ `2ae12c815b <https://github.com/apache/airflow/commit/2ae12c815bc704eff6890df56f7387da513d14f2>`__ 2025-04-16 ``Update documentation for edge3 and git provider (#49365)``
46
+ `dd0efe348b <https://github.com/apache/airflow/commit/dd0efe348b6ce94243ec7a727f9aa908eeafbc82>`__ 2025-04-16 ``Use 'git_default' if the user defines nothing (#49359)``
47
+ `ca3e4e75c6 <https://github.com/apache/airflow/commit/ca3e4e75c634afdceb23a86b7e0b0ff74614a7f1>`__ 2025-04-16 ``Prepare docs for Apr 3rd wave of providers (#49338)``
48
+ `192b337c86 <https://github.com/apache/airflow/commit/192b337c86eede5636f802d6f354fa97fe0f9030>`__ 2025-04-16 ``Don't log repo_url in git dag bundle (#48909)``
49
+ `2c7b56ee74 <https://github.com/apache/airflow/commit/2c7b56ee742409f65463534e34fa5f444d651af9>`__ 2025-04-15 ``Make git connection optional for git dag bundle (#49270)``
50
+ `b9052eed42 <https://github.com/apache/airflow/commit/b9052eed423f5f7f20c58815cce89e6cc659903c>`__ 2025-04-15 ``Include subdir in Gitbundle view url (#49239)``
51
+ ================================================================================================== =========== ============================================================
52
+
37
53
  0.0.1
38
54
  .....
39
55
 
40
- Latest change: 2025-04-09
56
+ Latest change: 2025-04-10
41
57
 
42
58
  ================================================================================================== =========== ==================================================================================
43
59
  Commit Committed Subject
44
60
  ================================================================================================== =========== ==================================================================================
61
+ `4a8567b20b <https://github.com/apache/airflow/commit/4a8567b20bdd6555cbdc936d6674bf4fa390b0d5>`__ 2025-04-10 ``Prepare docs for Apr 2nd wave of providers (#49051)``
45
62
  `4a1e2ff8ab <https://github.com/apache/airflow/commit/4a1e2ff8ab8e6abca1cb273dc55d651d971e49f2>`__ 2025-04-09 ``Mark git provider as ready (#48860)``
46
63
  `c68f31d3db <https://github.com/apache/airflow/commit/c68f31d3db6b957b4aeede7a257cc0ba59f12ce1>`__ 2025-04-08 ``Remove dev0 suffix from Airlfow version (#48934)``
47
64
  `7b2ec33c7a <https://github.com/apache/airflow/commit/7b2ec33c7ad4998d9c9735b79593fcdcd3b9dd1f>`__ 2025-04-08 ``Remove unnecessary entries in get_provider_info and update the schema (#48849)``
@@ -72,7 +72,7 @@ apache-airflow-providers-git package
72
72
  `Distributed version control system (GIT) <https://git-scm.com/>`__
73
73
 
74
74
 
75
- Release: 0.0.1
75
+ Release: 0.0.2
76
76
 
77
77
  Provider package
78
78
  ----------------
@@ -22,9 +22,10 @@ description: |
22
22
  `Distributed version control system (GIT) <https://git-scm.com/>`__
23
23
 
24
24
  state: ready
25
- source-date-epoch: 1742823216
25
+ source-date-epoch: 1744792049
26
26
  # note that those versions are maintained by release manager - do not update them manually
27
27
  versions:
28
+ - 0.0.2
28
29
  - 0.0.1
29
30
 
30
31
  integrations:
@@ -25,7 +25,7 @@ build-backend = "flit_core.buildapi"
25
25
 
26
26
  [project]
27
27
  name = "apache-airflow-providers-git"
28
- version = "0.0.1.rc1"
28
+ version = "0.0.2"
29
29
  description = "Provider package apache-airflow-providers-git for Apache Airflow"
30
30
  readme = "README.rst"
31
31
  authors = [
@@ -57,7 +57,7 @@ requires-python = "~=3.9"
57
57
  # Make sure to run ``breeze static-checks --type update-providers-dependencies --all-files``
58
58
  # After you modify the dependencies, and rebuild your Breeze CI image with ``breeze ci-image build``
59
59
  dependencies = [
60
- "apache-airflow>=3.0.0rc0",
60
+ "apache-airflow>=3.0.0",
61
61
  "GitPython>=3.1.44",
62
62
  ]
63
63
 
@@ -95,8 +95,8 @@ apache-airflow-providers-common-sql = {workspace = true}
95
95
  apache-airflow-providers-standard = {workspace = true}
96
96
 
97
97
  [project.urls]
98
- "Documentation" = "https://airflow.apache.org/docs/apache-airflow-providers-git/0.0.1"
99
- "Changelog" = "https://airflow.apache.org/docs/apache-airflow-providers-git/0.0.1/changelog.html"
98
+ "Documentation" = "https://airflow.apache.org/docs/apache-airflow-providers-git/0.0.2"
99
+ "Changelog" = "https://airflow.apache.org/docs/apache-airflow-providers-git/0.0.2/changelog.html"
100
100
  "Bug Tracker" = "https://github.com/apache/airflow/issues"
101
101
  "Source Code" = "https://github.com/apache/airflow"
102
102
  "Slack Chat" = "https://s.apache.org/airflow-slack"
@@ -29,7 +29,7 @@ from airflow import __version__ as airflow_version
29
29
 
30
30
  __all__ = ["__version__"]
31
31
 
32
- __version__ = "0.0.1"
32
+ __version__ = "0.0.2"
33
33
 
34
34
  if packaging.version.parse(packaging.version.parse(airflow_version).base_version) < packaging.version.parse(
35
35
  "3.0.0"
@@ -17,6 +17,7 @@
17
17
  from __future__ import annotations
18
18
 
19
19
  import os
20
+ from contextlib import nullcontext
20
21
  from pathlib import Path
21
22
  from urllib.parse import urlparse
22
23
 
@@ -53,7 +54,7 @@ class GitDagBundle(BaseDagBundle):
53
54
  *,
54
55
  tracking_ref: str,
55
56
  subdir: str | None = None,
56
- git_conn_id: str = "git_default",
57
+ git_conn_id: str | None = None,
57
58
  repo_url: str | None = None,
58
59
  **kwargs,
59
60
  ) -> None:
@@ -75,20 +76,26 @@ class GitDagBundle(BaseDagBundle):
75
76
  repo_path=self.repo_path,
76
77
  versions_path=self.versions_dir,
77
78
  git_conn_id=self.git_conn_id,
78
- repo_url=self.repo_url,
79
79
  )
80
80
 
81
81
  self._log.debug("bundle configured")
82
- try:
83
- self.hook = GitHook(git_conn_id=self.git_conn_id, repo_url=self.repo_url)
84
- self.repo_url = self.hook.repo_url
85
- self._log.debug("repo_url updated from hook", repo_url=self.repo_url)
86
- except AirflowException as e:
87
- self._log.warning("Could not create GitHook", conn_id=self.git_conn_id, exc=e)
82
+ self.hook: GitHook | None = None
83
+ if not repo_url:
84
+ if not git_conn_id:
85
+ self._log.debug("Neither git_conn_id nor repo_url provided; loading 'git_default'")
86
+ git_conn_id = "git_default"
87
+ try:
88
+ self.hook = GitHook(git_conn_id=git_conn_id)
89
+ except AirflowException as e:
90
+ self._log.warning("Could not create GitHook", conn_id=git_conn_id, exc=e)
91
+ else:
92
+ self.repo_url = self.hook.repo_url
93
+ self._log.debug("repo_url updated from hook")
88
94
 
89
95
  def _initialize(self):
90
96
  with self.lock():
91
- with self.hook.configure_hook_env():
97
+ cm = self.hook.configure_hook_env() if self.hook else nullcontext()
98
+ with cm:
92
99
  self._clone_bare_repo_if_required()
93
100
  self._ensure_version_in_bare_repo()
94
101
 
@@ -134,7 +141,7 @@ class GitDagBundle(BaseDagBundle):
134
141
  url=self.repo_url,
135
142
  to_path=self.bare_repo_path,
136
143
  bare=True,
137
- env=self.hook.env,
144
+ env=self.hook.env if self.hook else None,
138
145
  )
139
146
  except GitCommandError as e:
140
147
  raise AirflowException("Error cloning repository") from e
@@ -177,10 +184,10 @@ class GitDagBundle(BaseDagBundle):
177
184
 
178
185
  def _fetch_bare_repo(self):
179
186
  refspecs = ["+refs/heads/*:refs/heads/*", "+refs/tags/*:refs/tags/*"]
180
- if self.hook.env:
181
- with self.bare_repo.git.custom_environment(GIT_SSH_COMMAND=self.hook.env.get("GIT_SSH_COMMAND")):
182
- self.bare_repo.remotes.origin.fetch(refspecs)
183
- else:
187
+ cm = nullcontext()
188
+ if self.hook and (cmd := self.hook.env.get("GIT_SSH_COMMAND")):
189
+ cm = self.bare_repo.git.custom_environment(GIT_SSH_COMMAND=cmd)
190
+ with cm:
184
191
  self.bare_repo.remotes.origin.fetch(refspecs)
185
192
 
186
193
  def refresh(self) -> None:
@@ -188,7 +195,8 @@ class GitDagBundle(BaseDagBundle):
188
195
  raise AirflowException("Refreshing a specific version is not supported")
189
196
 
190
197
  with self.lock():
191
- with self.hook.configure_hook_env():
198
+ cm = self.hook.configure_hook_env() if self.hook else nullcontext()
199
+ with cm:
192
200
  self._fetch_bare_repo()
193
201
  self.repo.remotes.origin.fetch(
194
202
  ["+refs/heads/*:refs/remotes/origin/*", "+refs/tags/*:refs/tags/*"]
@@ -233,6 +241,8 @@ class GitDagBundle(BaseDagBundle):
233
241
  "gitlab.com": f"{url}/-/tree/{version}",
234
242
  "bitbucket.org": f"{url}/src/{version}",
235
243
  }
244
+ if self.subdir:
245
+ host_patterns = {k: f"{v}/{self.subdir}" for k, v in host_patterns.items()}
236
246
  for allowed_host, template in host_patterns.items():
237
247
  if host == allowed_host or host.endswith(f".{allowed_host}"):
238
248
  return template
@@ -17,6 +17,7 @@
17
17
 
18
18
  from __future__ import annotations
19
19
 
20
+ import json
20
21
  import os
21
22
  import re
22
23
  from unittest import mock
@@ -115,17 +116,17 @@ class TestGitDagBundle:
115
116
  tracking_ref=GIT_DEFAULT_BRANCH,
116
117
  repo_url="https://github.com/apache/zzzairflow",
117
118
  )
118
- assert bundle.repo_url == f"https://{ACCESS_TOKEN}@github.com/apache/zzzairflow"
119
+ assert bundle.repo_url == "https://github.com/apache/zzzairflow"
119
120
 
120
121
  def test_falls_back_to_connection_host_when_no_repo_url_provided(self):
121
- bundle = GitDagBundle(name="test", tracking_ref=GIT_DEFAULT_BRANCH)
122
+ bundle = GitDagBundle(name="test", git_conn_id=CONN_HTTPS, tracking_ref=GIT_DEFAULT_BRANCH)
122
123
  assert bundle.repo_url == bundle.hook.repo_url
123
124
 
124
125
  @mock.patch("airflow.providers.git.bundles.git.GitHook")
125
126
  def test_get_current_version(self, mock_githook, git_repo):
126
127
  repo_path, repo = git_repo
127
128
  mock_githook.return_value.repo_url = repo_path
128
- bundle = GitDagBundle(name="test", tracking_ref=GIT_DEFAULT_BRANCH)
129
+ bundle = GitDagBundle(name="test", git_conn_id=CONN_HTTPS, tracking_ref=GIT_DEFAULT_BRANCH)
129
130
 
130
131
  bundle.initialize()
131
132
 
@@ -146,6 +147,7 @@ class TestGitDagBundle:
146
147
 
147
148
  bundle = GitDagBundle(
148
149
  name="test",
150
+ git_conn_id=CONN_HTTPS,
149
151
  version=starting_commit.hexsha,
150
152
  tracking_ref=GIT_DEFAULT_BRANCH,
151
153
  )
@@ -174,6 +176,7 @@ class TestGitDagBundle:
174
176
 
175
177
  bundle = GitDagBundle(
176
178
  name="test",
179
+ git_conn_id=CONN_HTTPS,
177
180
  version="test",
178
181
  tracking_ref=GIT_DEFAULT_BRANCH,
179
182
  )
@@ -195,7 +198,7 @@ class TestGitDagBundle:
195
198
  repo.index.add([file_path])
196
199
  repo.index.commit("Another commit")
197
200
 
198
- bundle = GitDagBundle(name="test", tracking_ref=GIT_DEFAULT_BRANCH)
201
+ bundle = GitDagBundle(name="test", git_conn_id=CONN_HTTPS, tracking_ref=GIT_DEFAULT_BRANCH)
199
202
  bundle.initialize()
200
203
 
201
204
  assert bundle.get_current_version() != starting_commit.hexsha
@@ -221,7 +224,7 @@ class TestGitDagBundle:
221
224
  writer.set_value("user", "name", "Test User")
222
225
  writer.set_value("user", "email", "test@example.com")
223
226
 
224
- bundle = GitDagBundle(name="test", tracking_ref=GIT_DEFAULT_BRANCH)
227
+ bundle = GitDagBundle(name="test", git_conn_id=CONN_HTTPS, tracking_ref=GIT_DEFAULT_BRANCH)
225
228
  bundle.initialize()
226
229
 
227
230
  assert bundle.get_current_version() == starting_commit.hexsha
@@ -252,7 +255,7 @@ class TestGitDagBundle:
252
255
  # add tag
253
256
  repo.create_tag("test123")
254
257
 
255
- bundle = GitDagBundle(name="test", tracking_ref="test123")
258
+ bundle = GitDagBundle(name="test", git_conn_id=CONN_HTTPS, tracking_ref="test123")
256
259
  bundle.initialize()
257
260
  assert bundle.get_current_version() == starting_commit.hexsha
258
261
 
@@ -279,7 +282,7 @@ class TestGitDagBundle:
279
282
  mock_githook.return_value.repo_url = repo_path
280
283
 
281
284
  repo.create_head("test")
282
- bundle = GitDagBundle(name="test", tracking_ref="test")
285
+ bundle = GitDagBundle(name="test", git_conn_id=CONN_HTTPS, tracking_ref="test")
283
286
  bundle.initialize()
284
287
  assert bundle.repo.head.ref.name == "test"
285
288
 
@@ -289,6 +292,7 @@ class TestGitDagBundle:
289
292
  mock_githook.return_value.repo_url = repo_path
290
293
  bundle = GitDagBundle(
291
294
  name="test",
295
+ git_conn_id=CONN_HTTPS,
292
296
  version="not_found",
293
297
  tracking_ref=GIT_DEFAULT_BRANCH,
294
298
  )
@@ -313,6 +317,7 @@ class TestGitDagBundle:
313
317
 
314
318
  bundle = GitDagBundle(
315
319
  name="test",
320
+ git_conn_id=CONN_HTTPS,
316
321
  tracking_ref=GIT_DEFAULT_BRANCH,
317
322
  subdir=subdir,
318
323
  )
@@ -406,6 +411,93 @@ class TestGitDagBundle:
406
411
  )
407
412
  @mock.patch("airflow.providers.git.bundles.git.Repo")
408
413
  def test_view_url(self, mock_gitrepo, repo_url, extra_conn_kwargs, expected_url, session):
414
+ session.query(Connection).delete()
415
+ conn = Connection(
416
+ conn_id="my_git_connection",
417
+ host=repo_url,
418
+ conn_type="git",
419
+ **(extra_conn_kwargs or {}),
420
+ )
421
+ session.add(conn)
422
+ session.commit()
423
+ bundle = GitDagBundle(
424
+ name="test",
425
+ git_conn_id="my_git_connection",
426
+ tracking_ref="main",
427
+ )
428
+ bundle.initialize = mock.MagicMock()
429
+ view_url = bundle.view_url("0f0f0f")
430
+ assert view_url == expected_url
431
+ bundle.initialize.assert_not_called()
432
+
433
+ @pytest.mark.parametrize(
434
+ "repo_url, extra_conn_kwargs, expected_url",
435
+ [
436
+ (
437
+ "git@github.com:apache/airflow.git",
438
+ None,
439
+ "https://github.com/apache/airflow/tree/0f0f0f/subdir",
440
+ ),
441
+ ("git@github.com:apache/airflow", None, "https://github.com/apache/airflow/tree/0f0f0f/subdir"),
442
+ (
443
+ "https://github.com/apache/airflow",
444
+ None,
445
+ "https://github.com/apache/airflow/tree/0f0f0f/subdir",
446
+ ),
447
+ (
448
+ "https://github.com/apache/airflow.git",
449
+ None,
450
+ "https://github.com/apache/airflow/tree/0f0f0f/subdir",
451
+ ),
452
+ (
453
+ "git@gitlab.com:apache/airflow.git",
454
+ None,
455
+ "https://gitlab.com/apache/airflow/-/tree/0f0f0f/subdir",
456
+ ),
457
+ (
458
+ "git@bitbucket.org:apache/airflow.git",
459
+ None,
460
+ "https://bitbucket.org/apache/airflow/src/0f0f0f/subdir",
461
+ ),
462
+ (
463
+ "git@myorg.github.com:apache/airflow.git",
464
+ None,
465
+ "https://myorg.github.com/apache/airflow/tree/0f0f0f/subdir",
466
+ ),
467
+ (
468
+ "https://myorg.github.com/apache/airflow.git",
469
+ None,
470
+ "https://myorg.github.com/apache/airflow/tree/0f0f0f/subdir",
471
+ ),
472
+ (
473
+ "https://github.com/apache/airflow",
474
+ {"password": "abc123"},
475
+ "https://github.com/apache/airflow/tree/0f0f0f/subdir",
476
+ ),
477
+ (
478
+ "https://github.com/apache/airflow",
479
+ {"login": "abc123"},
480
+ "https://github.com/apache/airflow/tree/0f0f0f/subdir",
481
+ ),
482
+ (
483
+ "https://github.com/apache/airflow",
484
+ {"login": "abc123", "password": "def456"},
485
+ "https://github.com/apache/airflow/tree/0f0f0f/subdir",
486
+ ),
487
+ (
488
+ "https://github.com:443/apache/airflow",
489
+ None,
490
+ "https://github.com:443/apache/airflow/tree/0f0f0f/subdir",
491
+ ),
492
+ (
493
+ "https://github.com:443/apache/airflow",
494
+ {"password": "abc123"},
495
+ "https://github.com:443/apache/airflow/tree/0f0f0f/subdir",
496
+ ),
497
+ ],
498
+ )
499
+ @mock.patch("airflow.providers.git.bundles.git.Repo")
500
+ def test_view_url_subdir(self, mock_gitrepo, repo_url, extra_conn_kwargs, expected_url, session):
409
501
  session.query(Connection).delete()
410
502
  conn = Connection(
411
503
  conn_id="git_default",
@@ -418,6 +510,8 @@ class TestGitDagBundle:
418
510
  bundle = GitDagBundle(
419
511
  name="test",
420
512
  tracking_ref="main",
513
+ subdir="subdir",
514
+ git_conn_id="git_default",
421
515
  )
422
516
  bundle.initialize = mock.MagicMock()
423
517
  view_url = bundle.view_url("0f0f0f")
@@ -440,7 +534,7 @@ class TestGitDagBundle:
440
534
 
441
535
  with mock.patch("airflow.providers.git.bundles.git.Repo.clone_from") as mock_clone:
442
536
  mock_clone.side_effect = GitCommandError("clone", "Simulated error")
443
- bundle = GitDagBundle(name="test", tracking_ref="main")
537
+ bundle = GitDagBundle(name="test", git_conn_id=CONN_HTTPS, tracking_ref="main")
444
538
  with pytest.raises(
445
539
  AirflowException,
446
540
  match=re.escape("Error cloning repository"),
@@ -461,25 +555,46 @@ class TestGitDagBundle:
461
555
  assert "Repository path: %s not found" in str(exc_info.value)
462
556
 
463
557
  @patch.dict(os.environ, {"AIRFLOW_CONN_MY_TEST_GIT": '{"host": "something"}'})
464
- @pytest.mark.parametrize("conn_id, should_find", [("my_test_git", True), ("something-else", False)])
465
- def test_repo_url_access_missing_connection_doesnt_error(self, conn_id, should_find):
558
+ @pytest.mark.parametrize(
559
+ "conn_id, expected_hook_type",
560
+ [("my_test_git", GitHook), ("something-else", type(None))],
561
+ )
562
+ def test_repo_url_access_missing_connection_doesnt_error(self, conn_id, expected_hook_type):
466
563
  bundle = GitDagBundle(
467
564
  name="testa",
468
565
  tracking_ref="main",
469
566
  git_conn_id=conn_id,
470
- repo_url="some_repo_url",
471
567
  )
472
- assert bundle.repo_url == "some_repo_url"
473
- if should_find:
474
- assert isinstance(bundle.hook, GitHook)
475
- else:
476
- assert not hasattr(bundle, "hook")
568
+ assert isinstance(bundle.hook, expected_hook_type)
477
569
 
478
570
  @mock.patch("airflow.providers.git.bundles.git.GitHook")
479
571
  def test_lock_used(self, mock_githook, git_repo):
480
572
  repo_path, repo = git_repo
481
573
  mock_githook.return_value.repo_url = repo_path
482
- bundle = GitDagBundle(name="test", tracking_ref=GIT_DEFAULT_BRANCH)
574
+ bundle = GitDagBundle(name="test", git_conn_id=CONN_HTTPS, tracking_ref=GIT_DEFAULT_BRANCH)
483
575
  with mock.patch("airflow.providers.git.bundles.git.GitDagBundle.lock") as mock_lock:
484
576
  bundle.initialize()
485
577
  assert mock_lock.call_count == 2 # both initialize and refresh
578
+
579
+ @pytest.mark.parametrize(
580
+ "conn_json, repo_url, expected",
581
+ [
582
+ (
583
+ {"host": "git@github.com:apache/airflow.git"},
584
+ "git@github.com:apache/hello.git",
585
+ "git@github.com:apache/hello.git",
586
+ ),
587
+ ({"host": "git@github.com:apache/airflow.git"}, None, "git@github.com:apache/airflow.git"),
588
+ ({}, "git@github.com:apache/hello.git", "git@github.com:apache/hello.git"),
589
+ ],
590
+ )
591
+ def test_repo_url_precedence(self, conn_json, repo_url, expected):
592
+ conn_str = json.dumps(conn_json)
593
+ with patch.dict(os.environ, {"AIRFLOW_CONN_MY_TEST_GIT": conn_str}):
594
+ bundle = GitDagBundle(
595
+ name="test",
596
+ tracking_ref="main",
597
+ git_conn_id="my_test_git",
598
+ repo_url=repo_url,
599
+ )
600
+ assert bundle.repo_url == expected