Skip to content

Commit

Permalink
fix(core): regression in migration after git refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
m-alisafaee committed Nov 4, 2021
1 parent c50d893 commit ccb6572
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion renku/core/management/migrations/m_0005__2_cwl.py
Expand Up @@ -475,7 +475,7 @@ def find_previous_commit(self, path, revision="HEAD"):

def find_from_client(path, revision):
try:
return self.client.repository.get_previous_commit(paths=path, revision=revision, full_history=True)
return self.client.repository.get_previous_commit(path=path, revision=revision, full_history=True)
except errors.GitCommitNotFoundError:
communication.warn(f"Cannot find previous commit for {path} from {str(revision)}")
return revision
Expand Down
Expand Up @@ -506,7 +506,7 @@ def _convert_invalidated_entity(entity: old_schema.Entity, client) -> Optional[E
assert not isinstance(entity, old_schema.Collection), f"Collection passed as invalidated: {entity._id}"

commit_sha = _extract_commit_sha(entity_id=entity._id)
commit = client.repository.get_previous_commit(revision=commit_sha, paths=entity.path)
commit = client.repository.get_previous_commit(revision=commit_sha, path=entity.path)
revision = commit.hexsha
checksum = client.repository.get_object_hash(revision=revision, path=entity.path)
if not checksum:
Expand Down
8 changes: 6 additions & 2 deletions renku/core/metadata/repository.py
Expand Up @@ -286,12 +286,16 @@ def get_attributes(self, *paths: Union[Path, str]) -> Dict[str, Dict[str, str]]:

return attributes

def get_previous_commit(self, path: Union[Path, str], revision: Union["Commit", str] = None) -> Optional["Commit"]:
def get_previous_commit(
self, path: Union[Path, str], revision: Union["Commit", str] = None, full_history: bool = False
) -> Optional["Commit"]:
"""Return a previous commit for a given path starting from ``revision``."""
revision = revision or "HEAD"
assert isinstance(revision, (Commit, str)), f"'revision' must be Commit/str not '{type(revision)}'"

commit = _find_previous_commit_helper(repository=self, path=path, revision=str(revision))
commit = _find_previous_commit_helper(
repository=self, path=path, revision=str(revision), full_history=full_history
)
if not commit:
raise errors.GitCommitNotFoundError(f"Cannot find previous commit for '{path}' from '{revision}'")
return commit
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/test_datasets.py
Expand Up @@ -881,7 +881,7 @@ def test_datasets_ls_files_correct_commit(runner, client, directory_tree):
"""Test ls-files shows the size stored in git and not the current file size."""
assert 0 == runner.invoke(cli, ["dataset", "add", "my-dataset", "-c", str(directory_tree / "file1")]).exit_code

commit = client.repository.get_previous_commit(paths=client.path / DATA_DIR / "my-dataset" / "file1")
commit = client.repository.get_previous_commit(path=client.path / DATA_DIR / "my-dataset" / "file1")

# check include / exclude filters
result = runner.invoke(cli, ["dataset", "ls-files", "--columns=commit,path"])
Expand Down

0 comments on commit ccb6572

Please sign in to comment.