Clone *url* into *repo_dir* unless it's already that working copy. Returns ``True`` if a clone was performed, ``False`` if skipped.
(git_wrapper: GitCommandWrapper, base_dir: str,
repo_name: str, repo_dir: str, url: str,
git_token: Optional[str],
revision: Optional[str])
| 32 | |
| 33 | |
| 34 | def _clone_if_needed(git_wrapper: GitCommandWrapper, base_dir: str, |
| 35 | repo_name: str, repo_dir: str, url: str, |
| 36 | git_token: Optional[str], |
| 37 | revision: Optional[str]) -> bool: |
| 38 | """Clone *url* into *repo_dir* unless it's already that working copy. |
| 39 | |
| 40 | Returns ``True`` if a clone was performed, ``False`` if skipped. |
| 41 | """ |
| 42 | os.makedirs(repo_dir, exist_ok=True) |
| 43 | if os.listdir(repo_dir): |
| 44 | try: |
| 45 | existing = git_wrapper.get_repo_remote_url(repo_dir) |
| 46 | existing = git_wrapper.remove_token_from_url(existing) |
| 47 | if existing == url: |
| 48 | return False |
| 49 | except GitError: |
| 50 | pass |
| 51 | git_wrapper.clone(base_dir, git_token, url, repo_name, revision) |
| 52 | return True |
| 53 | |
| 54 | |
| 55 | class Repository: |
no test coverage detected
searching dependent graphs…