summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Maas <opensource@till.name>2014-02-14 19:45:00 +0100
committerTill Maas <opensource@till.name>2014-02-14 19:45:00 +0100
commitd8e06a7e0829c84aa7c773252030b73132df8500 (patch)
treec657bccaa08c6b8ca1a280afc239f46b2c6365c1
parent81aaf9409a83e35550705416425eb4aa6f806e05 (diff)
downloadcnucnu-d8e06a7e0829c84aa7c773252030b73132df8500.zip
cnucnu-d8e06a7e0829c84aa7c773252030b73132df8500.tar.gz
cnucnu-d8e06a7e0829c84aa7c773252030b73132df8500.tar.xz
Aliases: Adjust GITHUB-TAGS regex
- github tags might start with a character that does not belong to the version - Add testcase
-rw-r--r--cnucnu/__init__.py5
-rwxr-xr-xcnucnu/tests/aliases_test.py9
2 files changed, 13 insertions, 1 deletions
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)