From d8e06a7e0829c84aa7c773252030b73132df8500 Mon Sep 17 00:00:00 2001 From: Till Maas Date: Fri, 14 Feb 2014 19:45:00 +0100 Subject: Aliases: Adjust GITHUB-TAGS regex - github tags might start with a character that does not belong to the version - Add testcase --- cnucnu/__init__.py | 5 ++++- cnucnu/tests/aliases_test.py | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cnucnu/__init__.py b/cnucnu/__init__.py index 8c67f94..e96cfdc 100644 --- a/cnucnu/__init__.py +++ b/cnucnu/__init__.py @@ -55,7 +55,10 @@ ALIASES = { }, "GITHUB-TAGS": { "url": "https://api.github.com/repos/{name}/tags", - "regex": '"name":\s*"([\d\.]+)"', + # Match strings like: + # "name": "v0.3.0" + # "name": "1.2.3" + "regex": '"name":\s*"[^\d]*([\d\.]+)"', }, "GNU-DEFAULT": { "url": "http://ftp.gnu.org/gnu/{name}/" diff --git a/cnucnu/tests/aliases_test.py b/cnucnu/tests/aliases_test.py index f9bc899..1cd9254 100755 --- a/cnucnu/tests/aliases_test.py +++ b/cnucnu/tests/aliases_test.py @@ -22,6 +22,7 @@ import sys sys.path.insert(0, '../..') from cnucnu import unalias, ALIASES +from cnucnu.package_list import Package, Repository class AliasTest(unittest.TestCase): @@ -75,6 +76,14 @@ class AliasTest(unittest.TestCase): "http://pear.php.net/package/Test_Case/download/All" ) + def testGITHUBTags(self): + p = Package("cnucnu_test", "GITHUB-TAGS", "test_url", Repository()) + p._html = """ "name": "0.1.2" """ + self.assertEqual(p.upstream_versions, ["0.1.2"]) + + p._html = """ "name": "v0.1.2" """ + self.assertEqual(p.upstream_versions, ["0.1.2"]) + if __name__ == "__main__": suite = unittest.TestLoader().loadTestsFromTestCase(AliasTest) -- cgit