diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 55595798..cc29fa27 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -1171,18 +1171,11 @@ class vcs_git(vcs): p = FDroidPopen(['git', 'tag'], cwd=self.local, output=False) return p.output.splitlines() - tag_format = re.compile(r'tag: ([^),]*)') - def latesttags(self): self.checkrepo() - p = FDroidPopen(['git', 'log', '--tags', - '--simplify-by-decoration', '--pretty=format:%d'], + p = FDroidPopen(['git', 'tag', '--sort=-authordate'], cwd=self.local, output=False) - tags = [] - for line in p.output.splitlines(): - for tag in self.tag_format.findall(line): - tags.append(tag) - return tags + return p.output.splitlines() class vcs_gitsvn(vcs): diff --git a/tests/common.TestCase b/tests/common.TestCase index 38e7dd9b..b9c70959 100755 --- a/tests/common.TestCase +++ b/tests/common.TestCase @@ -2059,6 +2059,19 @@ class CommonTest(unittest.TestCase): {'r10e': r10e, 'r17c': ndk_bundle, 'r21e': r21e}, config['ndk_paths'] ) + def test_vcs_git_latesttags(self): + vcs = fdroidserver.common.vcs_git(None, None) + popenmock = mock.Mock() + popenmock.output = "8.9.5\n8.9.4\n8.6.3\n8,9,3" + with mock.patch( + 'fdroidserver.common.FDroidPopen', lambda a, **b: popenmock + ) as _ignored, mock.patch( + 'fdroidserver.common.vcs_git.checkrepo' + ) as _ignored: + _ignored # silence the linters + tags = vcs.latesttags() + self.assertEqual(tags, ['8.9.5', '8.9.4', '8.6.3', '8,9,3']) + if __name__ == "__main__": os.chdir(os.path.dirname(__file__))