Return commits in chronological order
Signed-off-by: Václav Valíček <valicek1994@gmail.com>
This commit is contained in:
parent
8bc6a7b578
commit
a2bf978fde
|
@ -216,7 +216,7 @@ class RepoTool:
|
||||||
|
|
||||||
@__check_initialized
|
@__check_initialized
|
||||||
def list_commits(self, max_depth: Optional[int] = None):
|
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
|
@__check_initialized
|
||||||
def list_submodules(self, commit: str = "HEAD") -> Union[list, bool]:
|
def list_submodules(self, commit: str = "HEAD") -> Union[list, bool]:
|
||||||
|
|
|
@ -467,10 +467,14 @@ def test_list_commits(cloned_base_repo_obj):
|
||||||
assert cloned_base_repo_obj.list_commits(3)
|
assert cloned_base_repo_obj.list_commits(3)
|
||||||
count = 0
|
count = 0
|
||||||
commits = set()
|
commits = set()
|
||||||
|
last_commit = ""
|
||||||
for commit in cloned_base_repo_obj.list_commits(20):
|
for commit in cloned_base_repo_obj.list_commits(20):
|
||||||
count += 1
|
count += 1
|
||||||
commits.add(commit.hexsha)
|
commits.add(commit.hexsha)
|
||||||
|
last_commit = commit.hexsha
|
||||||
assert count == 20
|
assert count == 20
|
||||||
|
# should be newest commit in repo
|
||||||
|
assert last_commit == "e0c7e2a72579e24657c05e875201011d2b48bf94"
|
||||||
|
|
||||||
assert commits == {
|
assert commits == {
|
||||||
'93e97409040f6e4ba5cebc4ddca679a2d3203efa', 'd8cd3257e05dc4a3d0061b5320ef5efd0b45d840',
|
'93e97409040f6e4ba5cebc4ddca679a2d3203efa', 'd8cd3257e05dc4a3d0061b5320ef5efd0b45d840',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user