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

dstandish 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 4ffa6afc721 Rename head to tracking ref (#44585)
4ffa6afc721 is described below

commit 4ffa6afc721ab99a974bb8bbda74b1d9300ae456
Author: Daniel Standish <[email protected]>
AuthorDate: Tue Dec 3 14:40:43 2024 -0800

    Rename head to tracking ref (#44585)
    
    Head is confusing cus in git speak it means "what you have checked out".  
That's not what we mean here.  Here we're trying to describe, most commonly, 
the branch in the repo that the user wants this bundle to track or "follow".  
Branch would be a good name, but technically it could also be a tag, or even a 
commit hash.
---
 airflow/dag_processing/bundles/git.py    | 10 +++++-----
 tests/dag_processing/test_dag_bundles.py | 20 +++++++++++---------
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/airflow/dag_processing/bundles/git.py 
b/airflow/dag_processing/bundles/git.py
index 2d6710d3eda..2022e613086 100644
--- a/airflow/dag_processing/bundles/git.py
+++ b/airflow/dag_processing/bundles/git.py
@@ -38,26 +38,26 @@ class GitDagBundle(BaseDagBundle):
     and then do a clone for each version from there.
 
     :param repo_url: URL of the git repository
-    :param head: Branch or tag for this DAG bundle
+    :param tracking_ref: Branch or tag for this DAG bundle
     :param subdir: Subdirectory within the repository where the DAGs are 
stored (Optional)
     """
 
     supports_versioning = True
 
-    def __init__(self, *, repo_url: str, head: str, subdir: str | None = None, 
**kwargs) -> None:
+    def __init__(self, *, repo_url: str, tracking_ref: str, subdir: str | None 
= None, **kwargs) -> None:
         super().__init__(**kwargs)
         self.repo_url = repo_url
-        self.head = head
+        self.tracking_ref = tracking_ref
         self.subdir = subdir
 
         self.bare_repo_path = self._dag_bundle_root_storage_path / "git" / 
self.name
         self.repo_path = (
-            self._dag_bundle_root_storage_path / "git" / (self.name + 
f"+{self.version or self.head}")
+            self._dag_bundle_root_storage_path / "git" / (self.name + 
f"+{self.version or self.tracking_ref}")
         )
         self._clone_bare_repo_if_required()
         self._ensure_version_in_bare_repo()
         self._clone_repo_if_required()
-        self.repo.git.checkout(self.head)
+        self.repo.git.checkout(self.tracking_ref)
 
         if self.version:
             if not self._has_version(self.repo, self.version):
diff --git a/tests/dag_processing/test_dag_bundles.py 
b/tests/dag_processing/test_dag_bundles.py
index 7489067bb82..345d54c5c0e 100644
--- a/tests/dag_processing/test_dag_bundles.py
+++ b/tests/dag_processing/test_dag_bundles.py
@@ -90,12 +90,12 @@ class TestGitDagBundle:
 
     def test_uses_dag_bundle_root_storage_path(self, git_repo):
         repo_path, repo = git_repo
-        bundle = GitDagBundle(name="test", repo_url=repo_path, head="master")
+        bundle = GitDagBundle(name="test", repo_url=repo_path, 
tracking_ref="master")
         assert str(bundle._dag_bundle_root_storage_path) in str(bundle.path)
 
     def test_get_current_version(self, git_repo):
         repo_path, repo = git_repo
-        bundle = GitDagBundle(name="test", repo_url=repo_path, head="master")
+        bundle = GitDagBundle(name="test", repo_url=repo_path, 
tracking_ref="master")
 
         assert bundle.get_current_version() == repo.head.commit.hexsha
 
@@ -110,7 +110,9 @@ class TestGitDagBundle:
         repo.index.add([file_path])
         repo.index.commit("Another commit")
 
-        bundle = GitDagBundle(name="test", version=starting_commit.hexsha, 
repo_url=repo_path, head="master")
+        bundle = GitDagBundle(
+            name="test", version=starting_commit.hexsha, repo_url=repo_path, 
tracking_ref="master"
+        )
 
         assert bundle.get_current_version() == starting_commit.hexsha
 
@@ -132,7 +134,7 @@ class TestGitDagBundle:
         repo.index.add([file_path])
         repo.index.commit("Another commit")
 
-        bundle = GitDagBundle(name="test", version="test", repo_url=repo_path, 
head="master")
+        bundle = GitDagBundle(name="test", version="test", repo_url=repo_path, 
tracking_ref="master")
 
         assert bundle.get_current_version() == starting_commit.hexsha
 
@@ -149,7 +151,7 @@ class TestGitDagBundle:
         repo.index.add([file_path])
         repo.index.commit("Another commit")
 
-        bundle = GitDagBundle(name="test", repo_url=repo_path, head="master")
+        bundle = GitDagBundle(name="test", repo_url=repo_path, 
tracking_ref="master")
 
         assert bundle.get_current_version() != starting_commit.hexsha
 
@@ -160,7 +162,7 @@ class TestGitDagBundle:
         repo_path, repo = git_repo
         starting_commit = repo.head.commit
 
-        bundle = GitDagBundle(name="test", repo_url=repo_path, head="master")
+        bundle = GitDagBundle(name="test", repo_url=repo_path, 
tracking_ref="master")
 
         assert bundle.get_current_version() == starting_commit.hexsha
 
@@ -184,14 +186,14 @@ class TestGitDagBundle:
         repo_path, repo = git_repo
 
         repo.create_head("test")
-        bundle = GitDagBundle(name="test", repo_url=repo_path, head="test")
+        bundle = GitDagBundle(name="test", repo_url=repo_path, 
tracking_ref="test")
         assert bundle.repo.head.ref.name == "test"
 
     def test_version_not_found(self, git_repo):
         repo_path, repo = git_repo
 
         with pytest.raises(AirflowException, match="Version not_found not 
found in the repository"):
-            GitDagBundle(name="test", version="not_found", repo_url=repo_path, 
head="master")
+            GitDagBundle(name="test", version="not_found", repo_url=repo_path, 
tracking_ref="master")
 
     def test_subdir(self, git_repo):
         repo_path, repo = git_repo
@@ -206,7 +208,7 @@ class TestGitDagBundle:
         repo.index.add([file_path])
         repo.index.commit("Initial commit")
 
-        bundle = GitDagBundle(name="test", repo_url=repo_path, head="master", 
subdir=subdir)
+        bundle = GitDagBundle(name="test", repo_url=repo_path, 
tracking_ref="master", subdir=subdir)
 
         files_in_repo = {f.name for f in bundle.path.iterdir() if f.is_file()}
         assert str(bundle.path).endswith(subdir)

Reply via email to