-
Notifications
You must be signed in to change notification settings - Fork 16.9k
Add skip on git clone when local version matches bundle version #63814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
56f8d7a
c8f455b
7e47034
00e0f53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -123,16 +123,41 @@ 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 | ||||||||||||||||||||
| repo = None | ||||||||||||||||||||
| try: | ||||||||||||||||||||
| repo = Repo(self.repo_path) | ||||||||||||||||||||
| expected_commit = repo.commit(self.version) | ||||||||||||||||||||
| has_version = repo.head.commit.hexsha == expected_commit.hexsha | ||||||||||||||||||||
| return has_version | ||||||||||||||||||||
| except (InvalidGitRepositoryError, NoSuchPathError, BadName, GitCommandError, ValueError): | ||||||||||||||||||||
| return False | ||||||||||||||||||||
| finally: | ||||||||||||||||||||
| if repo is not None: | ||||||||||||||||||||
| repo.close() | ||||||||||||||||||||
|
|
||||||||||||||||||||
| 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. A pruned worktree already exists (prune_dotgit_folder=True) | ||||||||||||||||||||
| # 2. The local repo already has the expected version | ||||||||||||||||||||
| if self._is_pruned_worktree(): | ||||||||||||||||||||
| self._log.debug( | ||||||||||||||||||||
| "Using existing pruned worktree", | ||||||||||||||||||||
| repo_path=self.repo_path, | ||||||||||||||||||||
| version=self.version, | ||||||||||||||||||||
| ) | ||||||||||||||||||||
| return | ||||||||||||||||||||
| if self._local_repo_has_version(): | ||||||||||||||||||||
| self._log.debug( | ||||||||||||||||||||
| "Using existing local repo with correct version", | ||||||||||||||||||||
| repo_path=self.repo_path, | ||||||||||||||||||||
| version=self.version, | ||||||||||||||||||||
| ) | ||||||||||||||||||||
|
||||||||||||||||||||
| ) | |
| ) | |
| if not self.prune_dotgit_folder and self.repo is None: | |
| try: | |
| self.repo = Repo(self.repo_path) | |
| except InvalidGitRepositoryError as e: | |
| raise RuntimeError(f"Invalid git repository at {self.repo_path}") from e | |
| if self.repo is not None: | |
| self.repo.close() |
Uh oh!
There was an error while loading. Please reload this page.