Skip to content

Commit

Permalink
fix(core): fix hash calculation when git returns too many paths (#2504)
Browse files Browse the repository at this point in the history
  • Loading branch information
Panaetius committed Dec 3, 2021
1 parent 942be48 commit 1788271
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions renku/core/metadata/repository.py
Expand Up @@ -462,7 +462,7 @@ def _get_hashes_from_revision(
if not revision:
uncommitted_hashes = _get_uncommitted_file_hashes(absolute_paths)

hashes.update({path_mapping[p]: h for p, h in uncommitted_hashes.items()})
hashes.update({path_mapping.get(p, p): h for p, h in uncommitted_hashes.items()})

if len(hashes) == len(absolute_paths):
# NOTE: there were only uncommitted files
Expand Down Expand Up @@ -495,15 +495,17 @@ def _get_hashes_from_revision(
if main_repo_paths:
# NOTE: Get hashes for paths in the main repository
revision_hashes = _get_hashes_from_revision(main_repo_paths, revision, self)
hashes.update({path_mapping[get_absolute_path(p, self.path)]: h for p, h in revision_hashes.items()})
hashes.update({path_mapping.get(get_absolute_path(p, self.path), p): h for p, h in revision_hashes.items()})

if not submodule_paths:
return hashes

# NOTE: Get hashes for paths in submodules
for submodule, submodule_paths in submodule_paths.items():
submodule_hashes = submodule.get_object_hashes(paths=submodule_paths, revision="HEAD")
hashes.update({path_mapping[get_absolute_path(p, self.path)]: h for p, h in submodule_hashes.items()})
hashes.update(
{path_mapping.get(get_absolute_path(p, self.path), p): h for p, h in submodule_hashes.items()}
)

return hashes

Expand Down

0 comments on commit 1788271

Please sign in to comment.