Use git tag in latesttags

This commit is contained in:
Jochen Sprickerhof 2021-06-14 18:56:59 +00:00
parent 89762f4d48
commit 2de3431296
2 changed files with 15 additions and 9 deletions

View File

@ -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):

View File

@ -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__))