ronaldorcampos commented on code in PR #63814:
URL: https://github.com/apache/airflow/pull/63814#discussion_r3026975369
##########
providers/git/src/airflow/providers/git/bundles/git.py:
##########
@@ -123,16 +123,37 @@ def _is_pruned_worktree(self) -> bool:
return False
return not (self.repo_path / ".git").exists()
+ def _local_repo_has_version(self) -> bool:
+ """Check if the local repo already has the correct version checked
out."""
+ if not self.version or not self.repo_path.is_dir() or not
(self.repo_path / ".git").exists():
+ return False
+ try:
+ repo = Repo(self.repo_path)
+ has_version = repo.head.commit.hexsha == self.version
+ repo.close()
+ return has_version
+ except Exception: # general exception just to catch anything wrong
with repo
+ return False
Review Comment:
good call
##########
providers/git/src/airflow/providers/git/bundles/git.py:
##########
@@ -123,16 +123,37 @@ def _is_pruned_worktree(self) -> bool:
return False
return not (self.repo_path / ".git").exists()
+ def _local_repo_has_version(self) -> bool:
+ """Check if the local repo already has the correct version checked
out."""
+ if not self.version or not self.repo_path.is_dir() or not
(self.repo_path / ".git").exists():
+ return False
+ try:
+ repo = Repo(self.repo_path)
+ has_version = repo.head.commit.hexsha == self.version
+ repo.close()
+ return has_version
+ except Exception: # general exception just to catch anything wrong
with repo
+ return False
+
def _initialize(self):
with self.lock():
- # Avoids re-cloning on every task run when
prune_dotgit_folder=True.
+ # Avoids re-cloning on every task run when:
+ # 1. prune_dotgit_folder=True
+ # 2. When local version matches expected version
Review Comment:
ok
--
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]