summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBelkadi & Save2013-01-02 15:43:36 +0100
committerYacine Belkadi2013-01-10 16:51:16 +0100
commit9be59a721c77065366974967d7bac7584f9606a3 (patch)
tree617871c86c8a3066e7c3c288f6d0bdab62efd902
parent53b44cc9a7f9c68ce6b727a11e37d4359504e55e (diff)
cleo/bundle_delivery: recognize tags of other projects, refs #3247
Instead of requiring each project (eoc-drv, eoc, ppc, etc) to modify the regex in bundle_delivery, just make it generic.
-rwxr-xr-xcleopatre/bundle_delivery.py18
-rwxr-xr-xcleopatre/devkit/tests/bundle_delivery/test_bundle_delivery.py5
2 files changed, 14 insertions, 9 deletions
diff --git a/cleopatre/bundle_delivery.py b/cleopatre/bundle_delivery.py
index 0631cbb098..709a52404a 100755
--- a/cleopatre/bundle_delivery.py
+++ b/cleopatre/bundle_delivery.py
@@ -173,7 +173,7 @@ class Tag:
version: the version of a tag. e.g. (1, 2, 0) or (1, 1, 3, "tmp").
"""
- re_tagname = re.compile("(?P<project>av)" +
+ re_tagname = re.compile("(?P<project>[a-z]+(-[a-z]+)*)" +
"-(?P<version>\d+\.\d+\.\d+)" +
"-?(?P<extra>.*)")
@@ -340,14 +340,14 @@ class BundleDiff:
def _id_tag_or_file(self, bundle):
"""Identify whether what was provided is a tag name or a filename."""
- file = None
- # First, let's suppose it's a tag.
- tag = Tag.from_tagname(bundle)
- if tag is None:
- # Maybe the filename of a bundle, then?
- tag = Tag.from_filename(bundle)
- if tag:
- file = bundle
+ # First, let's suppose it's the filename of a bundle.
+ tag = Tag.from_filename(bundle)
+ if tag:
+ file = bundle
+ else:
+ # Maybe a tag, then?
+ tag = Tag.from_tagname(bundle)
+ file = None
return (tag, file)
def gen_diff_file(self, bundle1, bundle2):
diff --git a/cleopatre/devkit/tests/bundle_delivery/test_bundle_delivery.py b/cleopatre/devkit/tests/bundle_delivery/test_bundle_delivery.py
index 6ea7764684..0345078fbe 100755
--- a/cleopatre/devkit/tests/bundle_delivery/test_bundle_delivery.py
+++ b/cleopatre/devkit/tests/bundle_delivery/test_bundle_delivery.py
@@ -27,6 +27,11 @@ class TestBundleDiff(unittest.TestCase):
self.assertTrue(tag is not None)
self.assertEqual(file, "testfiles/SPiDBundle-av-1.2.0.tar.bz2")
+ (tag, file) = b._id_tag_or_file(
+ "SPiDBundle-av-1.2.0.tar.bz2")
+ self.assertTrue(tag is not None)
+ self.assertEqual(file, "SPiDBundle-av-1.2.0.tar.bz2")
+
def test_gen_diff_file__two_tags(self):
b = BundleDiff(StubRepo(), StubBundleStorage())
diff_file = b.gen_diff_file("av-1.2.0", "av-1.2.1")