Skip to content

Commit f381efb

Browse files
committed
Update repo depending on presence of translation repositories
1 parent 5246dbb commit f381efb

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

completion.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,20 @@ def get_completion(clones_dir: str, repo: str) -> tuple[float, str, float]:
2323
clone_path = Path(clones_dir, 'translations', repo)
2424
for branch in branches_from_peps() + ['master', 'main']:
2525
try:
26-
clone_repo = git.Repo.clone_from(
27-
f'https://github.com/{repo}.git', clone_path, branch=branch
28-
)
26+
if not clone_path.exists():
27+
clone_repo = git.Repo.clone_from(
28+
f'https://github.com/{repo}.git', clone_path, branch=branch
29+
)
30+
else:
31+
(clone_repo := git.Repo(clone_path)).git.fetch()
32+
clone_repo.git.switch(branch)
33+
clone_repo.git.pull()
2934
except git.GitCommandError:
30-
print(f'failed to clone {repo} {branch}')
35+
print(f'failed to clone or switch to {repo} {branch}')
3136
branch = ''
3237
continue
3338
else:
39+
print(f'successfully cloned or switched to {repo} {branch}')
3440
break
3541
path_for_merge = Path(clones_dir, 'rebased_translations', repo)
3642
completion = potodo.merge_and_scan_paths(

0 commit comments

Comments
 (0)