booysej commented on code in PR #75750:
URL: https://github.com/apache/airflow/pull/75750#discussion_r4399472274


##########
providers/git/src/airflow/providers/git/bundles/git.py:
##########
@@ -231,38 +276,24 @@ def _initialize(self):
                 self._ensure_version_in_bare_repo()
             self.bare_repo.close()
 
-            try:
-                self._clone_repo_if_required()
-            except GitCommandError as e:
-                raise RuntimeError("Error cloning repository") from e
-            except InvalidGitRepositoryError as e:
-                raise RuntimeError(f"Invalid git repository at 
{self.repo_path}") from e
-            # If tracking_ref was just repointed to a SHA that predates this 
working clone's
-            # last fetch, this checkout fails until the clone is fetched or 
storage is cleared;
-            # tracked at https://github.com/apache/airflow/issues/71388
-            self.repo.git.checkout(self.tracking_ref)
-            self._log.debug("bundle initialize", version=self.version)
             if self.version:
-                if not self._has_version(self.repo, self.version):
-                    self.repo.remotes.origin.fetch()
-                
self.repo.head.set_reference(str(self.repo.commit(self.version)))
-                self.repo.head.reset(index=True, working_tree=True)
-
-                if self.submodules:
-                    cm_sub = self.hook.configure_hook_env() if self.hook else 
nullcontext()
-                    with cm_sub:
-                        try:
-                            self._fetch_submodules()
-                        except GitCommandError as e:
-                            raise RuntimeError("Error pulling submodule from 
repository") from e
-
-                if self.prune_dotgit_folder:
-                    self.repo.close()
-                    shutil.rmtree(self.repo_path / ".git")
-                    self.repo = None
+                self._initialize_versioned_repo()
             else:
+                try:
+                    self._clone_repo_if_required()
+                except GitCommandError as e:
+                    raise RuntimeError("Error cloning repository") from e
+                except InvalidGitRepositoryError as e:
+                    raise RuntimeError(f"Invalid git repository at 
{self.repo_path}") from e
+                if re.fullmatch(r"[0-9a-f]{40}", self.tracking_ref):

Review Comment:
   Addressed in `89e05f6d97`. `GitDagBundle` now fetches branch and tag refs 
before checkout in both versioned and unversioned initialization paths, so 
newly pushed tags are available before checkout. Added regression coverage; the 
full GitDagBundle test file passes with 119 tests.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to