diff --git a/renku/core/management/migrations/m_0005__2_cwl.py b/renku/core/management/migrations/m_0005__2_cwl.py index 058bde1f08..d2c44b41fd 100644 --- a/renku/core/management/migrations/m_0005__2_cwl.py +++ b/renku/core/management/migrations/m_0005__2_cwl.py @@ -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 diff --git a/renku/core/management/migrations/m_0009__new_metadata_storage.py b/renku/core/management/migrations/m_0009__new_metadata_storage.py index 946e0340a9..32db3b2d8e 100644 --- a/renku/core/management/migrations/m_0009__new_metadata_storage.py +++ b/renku/core/management/migrations/m_0009__new_metadata_storage.py @@ -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: diff --git a/renku/core/metadata/repository.py b/renku/core/metadata/repository.py index 1005c6a5bd..c710a890a9 100644 --- a/renku/core/metadata/repository.py +++ b/renku/core/metadata/repository.py @@ -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 diff --git a/tests/cli/test_datasets.py b/tests/cli/test_datasets.py index 3be552665b..bad935c7e2 100644 --- a/tests/cli/test_datasets.py +++ b/tests/cli/test_datasets.py @@ -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"])