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


##########
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:
   Fixed in 08b321e, and the regression test I offered is now in a479772.
   
   It injects a `PermissionError` when the on-disk tracking repo is opened and 
asserts initialization falls through to the full path instead of propagating. 
The assertion is deliberately indirect: it checks the bundle ends up on a 
commit that only the fallback could have picked up (the fallback fetches, the 
reuse path does not), so the test still fails if the error is swallowed and 
stale state is served.



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