Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class TestGetDagVersion(TestDagVersionEndpoint):
{
"bundle_name": "another_bundle_name",
"bundle_version": "some_commit_hash",
"bundle_url": None,
"bundle_url": "fakeprotocol://test_host.github.com/tree/some_commit_hash/dags",
"created_at": mock.ANY,
"dag_id": "ANOTHER_DAG_ID",
"id": mock.ANY,
Expand All @@ -69,7 +69,7 @@ class TestGetDagVersion(TestDagVersionEndpoint):
{
"bundle_name": "dag_maker",
"bundle_version": "some_commit_hash1",
"bundle_url": None,
"bundle_url": "fakeprotocol://test_host.github.com/tree/some_commit_hash1/dags",
"created_at": mock.ANY,
"dag_id": "dag_with_multiple_versions",
"id": mock.ANY,
Expand All @@ -82,7 +82,7 @@ class TestGetDagVersion(TestDagVersionEndpoint):
{
"bundle_name": "dag_maker",
"bundle_version": "some_commit_hash2",
"bundle_url": None,
"bundle_url": "fakeprotocol://test_host.github.com/tree/some_commit_hash2/dags",
"created_at": mock.ANY,
"dag_id": "dag_with_multiple_versions",
"id": mock.ANY,
Expand All @@ -95,7 +95,7 @@ class TestGetDagVersion(TestDagVersionEndpoint):
{
"bundle_name": "dag_maker",
"bundle_version": "some_commit_hash3",
"bundle_url": None,
"bundle_url": "fakeprotocol://test_host.github.com/tree/some_commit_hash3/dags",
"created_at": mock.ANY,
"dag_id": "dag_with_multiple_versions",
"id": mock.ANY,
Expand Down Expand Up @@ -139,7 +139,7 @@ class TestGetDagVersions(TestDagVersionEndpoint):
{
"bundle_name": "another_bundle_name",
"bundle_version": "some_commit_hash",
"bundle_url": None,
"bundle_url": "fakeprotocol://test_host.github.com/tree/some_commit_hash/dags",
"created_at": mock.ANY,
"dag_id": "ANOTHER_DAG_ID",
"id": mock.ANY,
Expand All @@ -148,7 +148,7 @@ class TestGetDagVersions(TestDagVersionEndpoint):
{
"bundle_name": "dag_maker",
"bundle_version": "some_commit_hash1",
"bundle_url": None,
"bundle_url": "fakeprotocol://test_host.github.com/tree/some_commit_hash1/dags",
"created_at": mock.ANY,
"dag_id": "dag_with_multiple_versions",
"id": mock.ANY,
Expand All @@ -157,7 +157,7 @@ class TestGetDagVersions(TestDagVersionEndpoint):
{
"bundle_name": "dag_maker",
"bundle_version": "some_commit_hash2",
"bundle_url": None,
"bundle_url": "fakeprotocol://test_host.github.com/tree/some_commit_hash2/dags",
"created_at": mock.ANY,
"dag_id": "dag_with_multiple_versions",
"id": mock.ANY,
Expand All @@ -166,7 +166,7 @@ class TestGetDagVersions(TestDagVersionEndpoint):
{
"bundle_name": "dag_maker",
"bundle_version": "some_commit_hash3",
"bundle_url": None,
"bundle_url": "fakeprotocol://test_host.github.com/tree/some_commit_hash3/dags",
"created_at": mock.ANY,
"dag_id": "dag_with_multiple_versions",
"id": mock.ANY,
Expand All @@ -183,7 +183,7 @@ class TestGetDagVersions(TestDagVersionEndpoint):
{
"bundle_name": "dag_maker",
"bundle_version": "some_commit_hash1",
"bundle_url": None,
"bundle_url": "fakeprotocol://test_host.github.com/tree/some_commit_hash1/dags",
"created_at": mock.ANY,
"dag_id": "dag_with_multiple_versions",
"id": mock.ANY,
Expand All @@ -192,7 +192,7 @@ class TestGetDagVersions(TestDagVersionEndpoint):
{
"bundle_name": "dag_maker",
"bundle_version": "some_commit_hash2",
"bundle_url": None,
"bundle_url": "fakeprotocol://test_host.github.com/tree/some_commit_hash2/dags",
"created_at": mock.ANY,
"dag_id": "dag_with_multiple_versions",
"id": mock.ANY,
Expand All @@ -201,7 +201,7 @@ class TestGetDagVersions(TestDagVersionEndpoint):
{
"bundle_name": "dag_maker",
"bundle_version": "some_commit_hash3",
"bundle_url": None,
"bundle_url": "fakeprotocol://test_host.github.com/tree/some_commit_hash3/dags",
"created_at": mock.ANY,
"dag_id": "dag_with_multiple_versions",
"id": mock.ANY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def test_should_respond_200_with_versions(self, test_client, run_id, expected_ve
"dag_id": "dag_with_multiple_versions",
"bundle_name": "dag_maker",
"bundle_version": f"some_commit_hash{expected_version_number}",
"bundle_url": None,
"bundle_url": f"fakeprotocol://test_host.github.com/tree/some_commit_hash{expected_version_number}/dags",
"created_at": mock.ANY,
},
}
Expand Down Expand Up @@ -1961,7 +1961,7 @@ def test_should_respond_200_with_versions(self, test_client, run_id, expected_ve
"dag_id": "dag_with_multiple_versions",
"bundle_name": "dag_maker",
"bundle_version": f"some_commit_hash{expected_version_number}",
"bundle_url": None,
"bundle_url": f"fakeprotocol://test_host.github.com/tree/some_commit_hash{expected_version_number}/dags",
"created_at": mock.ANY,
},
}
Expand Down Expand Up @@ -3023,7 +3023,7 @@ def test_should_respond_200_with_versions(self, test_client, run_id, expected_ve
"dag_id": "dag_with_multiple_versions",
"bundle_name": "dag_maker",
"bundle_version": f"some_commit_hash{expected_version_number}",
"bundle_url": None,
"bundle_url": f"fakeprotocol://test_host.github.com/tree/some_commit_hash{expected_version_number}/dags",
"created_at": mock.ANY,
},
}
Expand Down
9 changes: 6 additions & 3 deletions providers/git/src/airflow/providers/git/bundles/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,14 @@ def __init__(

self._log.debug("bundle configured")
self.hook: GitHook | None = None
if self.git_conn_id:
if not repo_url:
if not git_conn_id:
self._log.debug("Neither git_conn_id nor repo_url provided; loading 'git_default'")
git_conn_id = "git_default"
try:
self.hook = GitHook(git_conn_id=self.git_conn_id, repo_url=self.repo_url)
self.hook = GitHook(git_conn_id=git_conn_id)
except AirflowException as e:
self._log.warning("Could not create GitHook", conn_id=self.git_conn_id, exc=e)
self._log.warning("Could not create GitHook", conn_id=git_conn_id, exc=e)
else:
self.repo_url = self.hook.repo_url
self._log.debug("repo_url updated from hook")
Expand Down
4 changes: 1 addition & 3 deletions providers/git/tests/unit/git/bundles/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_https_access_token_repo_url_overrides_connection_host_when_provided(sel
tracking_ref=GIT_DEFAULT_BRANCH,
repo_url="https://github.com/apache/zzzairflow",
)
assert bundle.repo_url == f"https://{ACCESS_TOKEN}@github.com/apache/zzzairflow"
assert bundle.repo_url == "https://github.com/apache/zzzairflow"

def test_falls_back_to_connection_host_when_no_repo_url_provided(self):
bundle = GitDagBundle(name="test", git_conn_id=CONN_HTTPS, tracking_ref=GIT_DEFAULT_BRANCH)
Expand Down Expand Up @@ -564,9 +564,7 @@ def test_repo_url_access_missing_connection_doesnt_error(self, conn_id, expected
name="testa",
tracking_ref="main",
git_conn_id=conn_id,
repo_url="some_repo_url",
)
assert bundle.repo_url == "some_repo_url"
assert isinstance(bundle.hook, expected_hook_type)

@mock.patch("airflow.providers.git.bundles.git.GitHook")
Expand Down
Loading