From 596f06d5c05aff91ed644d8c07c75a17936825d6 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 24 Oct 2017 09:06:32 -0700 Subject: [PATCH] Fix list_commits sort order. It appears that with libgit2 v0.24.6 reverse causes it to list them newest first. In 0.25.1 it lists them oldest first. On both versions just using SortMode.TIME gives the desired result of oldest first. --- src/pylorax/api/recipes.py | 2 +- tests/pylorax/test_recipes.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pylorax/api/recipes.py b/src/pylorax/api/recipes.py index 8b0faa6c..700662f9 100644 --- a/src/pylorax/api/recipes.py +++ b/src/pylorax/api/recipes.py @@ -568,7 +568,7 @@ def list_commits(repo, branch, filename): :raises: Can raise errors from Ggit """ revwalk = Git.RevisionWalker.new(repo) - revwalk.set_sort_mode(Git.SortMode.TIME | Git.SortMode.REVERSE) + revwalk.set_sort_mode(Git.SortMode.TIME) branch_ref = "refs/heads/%s" % branch revwalk.push_ref(branch_ref) diff --git a/tests/pylorax/test_recipes.py b/tests/pylorax/test_recipes.py index cf1da3a2..cd6110cc 100644 --- a/tests/pylorax/test_recipes.py +++ b/tests/pylorax/test_recipes.py @@ -188,7 +188,7 @@ class GitRecipesTest(unittest.TestCase): commits = recipes.list_commits(self.repo, "master", "http-server.toml") self.assertEqual(len(commits), 2, "Wrong number of commits: %s" % commits) - self.assertEqual(commits[1].message, "Recipe http-server.toml reverted to commit %s" % revert_to) + self.assertEqual(commits[0].message, "Recipe http-server.toml reverted to commit %s" % revert_to) def test_10_tag_new_commit(self): """Test tagging a newer commit of a recipe"""