diff --git a/repo_cloner/lib/repo_tool.py b/repo_cloner/lib/repo_tool.py index c0e3bea..52e88ab 100644 --- a/repo_cloner/lib/repo_tool.py +++ b/repo_cloner/lib/repo_tool.py @@ -216,7 +216,7 @@ class RepoTool: @__check_initialized def list_commits(self, max_depth: Optional[int] = None): - return self._repo.iter_commits(all = True, max_count = max_depth) + return self._repo.iter_commits(all = True, max_count = max_depth, reverse = True) @__check_initialized def list_submodules(self, commit: str = "HEAD") -> Union[list, bool]: diff --git a/tests/lib/test_repo_tool.py b/tests/lib/test_repo_tool.py index 42a14c7..4d3a640 100644 --- a/tests/lib/test_repo_tool.py +++ b/tests/lib/test_repo_tool.py @@ -467,10 +467,14 @@ def test_list_commits(cloned_base_repo_obj): assert cloned_base_repo_obj.list_commits(3) count = 0 commits = set() + last_commit = "" for commit in cloned_base_repo_obj.list_commits(20): count += 1 commits.add(commit.hexsha) + last_commit = commit.hexsha assert count == 20 + # should be newest commit in repo + assert last_commit == "e0c7e2a72579e24657c05e875201011d2b48bf94" assert commits == { '93e97409040f6e4ba5cebc4ddca679a2d3203efa', 'd8cd3257e05dc4a3d0061b5320ef5efd0b45d840',