Skip to content

Commit

Permalink
self heal cache repo
Browse files Browse the repository at this point in the history
  • Loading branch information
cicd_zoo committed Mar 11, 2024
1 parent 96747f6 commit 639f843
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions gimera/gimera.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python3
import shutil
import threading
import traceback
import time
import tempfile
import re
Expand Down Expand Up @@ -378,7 +380,8 @@ def _pull_repo(index, main_repo, repo_yml):
_fetch_and_reset_branch(repo, repo_yml)

except Exception as ex:
results["errors"][index] = ex
trace = traceback.format_exc()
results["errors"][main_repo.path] = f"{ex}\n\n{trace}"

threads = []
for index, repo in enumerate(repos):
Expand Down Expand Up @@ -465,7 +468,12 @@ def _get_cache_dir(main_repo, repo_yml):
"/", "_"
)
path.parent.mkdir(exist_ok=True, parents=True)
if not path.exists():
is_broken = False

if path.exists() and not (path / '.git').exists():
shutil.rmtree(path)

if not path.exists() or is_broken:
click.secho(
f"Caching the repository {repo_yml.url} for quicker reuse",
fg="yellow",
Expand Down

0 comments on commit 639f843

Please sign in to comment.