Sanjays2402 commented on code in PR #70058:
URL: https://github.com/apache/airflow/pull/70058#discussion_r3610110970


##########
providers/git/src/airflow/providers/git/bundles/git.py:
##########
@@ -195,6 +205,38 @@ def _initialize(self):
                         self.repo = repo
                     return
 
+            if (
+                not self.version
+                and not self.refresh_on_initialize
+                and (self.repo_path / ".git").exists()
+                and self.bare_repo_path.exists()
+            ):
+                # The tracking repo is already on disk and the caller opted 
out of refreshing on
+                # initialize - reuse it as-is and skip all network operations. 
Fall through to the
+                # full initialization path if the on-disk repos turn out to be 
unusable. Both repo
+                # handles are still assigned so a later explicit refresh() 
works as usual.
+                try:
+                    repo = Repo(self.repo_path)
+                    try:
+                        repo.git.checkout(self.tracking_ref)
+                        bare_repo = Repo(self.bare_repo_path)
+                    except Exception:
+                        repo.close()
+                        raise
+                except (InvalidGitRepositoryError, NoSuchPathError, 
GitCommandError) as e:

Review Comment:
   the inner block re-raises non-git errors (the bare `raise` after close), but 
this outer except only catches 
InvalidGitRepositoryError/NoSuchPathError/GitCommandError. so a checkout 
failing with something like a PermissionError or OSError on the on-disk repo 
escapes here instead of falling through to full initialization, which defeats 
the "reuse it as-is, fall back if unusable" intent in the comment. intended?



-- 
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