Skip to content
Snippets Groups Projects
Commit 59048a48 authored by Filippo Cremonese's avatar Filippo Cremonese
Browse files

More robust git ls-remote handling

parent 7f232ec6
No related branches found
No related tags found
No related merge requests found
......@@ -70,15 +70,16 @@ class CloneAction(Action):
check_returncode=False
).stdout.decode("utf-8")
if os.path.exists(cache_filepath):
with open(cache_filepath, "rb") as f:
cached_data = json.loads(f.read())
else:
cached_data = {}
cached_data[self.build.qualified_name] = data
# TODO: prevent race condition, if two clone actions run at the same time
with open(cache_filepath, "w") as f:
json.dump(cached_data, f)
if data:
if os.path.exists(cache_filepath):
with open(cache_filepath, "rb") as f:
cached_data = json.loads(f.read())
else:
cached_data = {}
cached_data[self.build.qualified_name] = data
# TODO: prevent race condition, if two clone actions run at the same time
with open(cache_filepath, "w") as f:
json.dump(cached_data, f)
return data
......@@ -38,6 +38,12 @@ def handle_update(args, config: Configuration):
if os.path.exists(ls_remote_cache):
os.remove(ls_remote_cache)
for _, component in config.components.items():
for _, build in component.builds.items():
if build.clone:
logger.debug(f"Updating ls-remote cached info for {build.qualified_name}")
build.clone.get_remote_head()
logger.info("Updating repositories")
for git_repo in glob(os.path.join(config.sources_dir, "**/.git"), recursive=True):
git_repo = os.path.dirname(git_repo)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment