[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Fixing the reg exp to accept git SHA1 in Version



commit 292a90b6aac0574453f0187f3705e84aee59f808
Author: Sathyanarayanan Gunasekaran <gsathya.ceg@xxxxxxxxx>
Date:   Mon Dec 19 22:20:01 2011 +0530

    Fixing the reg exp to accept git SHA1 in Version
    
    Originally the reg exp checked didn't take into account
    the git commit [0.2.2.23-alpha (git-7dcd105be34a4f44)],
    which produced an Error. Now, the status tag consumes the
    git SHA1 as well.
    
    Appropriate test cases have been added for integ testing.
---
 stem/version.py      |    4 ++--
 test/unit/version.py |    7 ++++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/stem/version.py b/stem/version.py
index 26080cc..b984125 100644
--- a/stem/version.py
+++ b/stem/version.py
@@ -88,14 +88,14 @@ class Version:
   def __init__(self, version_str):
     """
     Parses a valid tor version string, for instance "0.1.4" or
-    "0.2.2.23-alpha".
+    "0.2.2.23-alpha (git-7dcd105be34a4f44)".
     
     Raises:
       ValueError if input isn't a valid tor version
     """
     
     self.version_str = version_str
-    m = re.match(r'^([0-9]+).([0-9]+).([0-9]+)(.[0-9]+)?(-\S*)?$', version_str)
+    m = re.match(r'^([0-9]+).([0-9]+).([0-9]+)(.[0-9]+)?(-.*)?$', version_str)
     
     if m:
       major, minor, micro, patch, status = m.groups()
diff --git a/test/unit/version.py b/test/unit/version.py
index 7cff127..787d9c8 100644
--- a/test/unit/version.py
+++ b/test/unit/version.py
@@ -16,6 +16,10 @@ class TestVersion(unittest.TestCase):
     """
     
     # valid versions with various number of compontents to the version
+    
+    version = stem.version.Version("0.1.2.3-tag (git-7dcd105be34a4f44)")
+    self.assert_versions_match(version, 0, 1, 2, 3, "tag (git-7dcd105be34a4f44)")
+    
     version = stem.version.Version("0.1.2.3-tag")
     self.assert_versions_match(version, 0, 1, 2, 3, "tag")
     
@@ -50,6 +54,7 @@ class TestVersion(unittest.TestCase):
     
     # check for basic incrementing in each portion
     self.assert_version_is_greater("1.1.2.3-tag", "0.1.2.3-tag")
+    self.assert_version_is_greater("1.1.2.3-tag (git-7dcd105be34a4f44)", "0.1.2.3-tag (git-7dcd105be34a4f44)")
     self.assert_version_is_greater("0.2.2.3-tag", "0.1.2.3-tag")
     self.assert_version_is_greater("0.1.3.3-tag", "0.1.2.3-tag")
     self.assert_version_is_greater("0.1.2.4-tag", "0.1.2.3-tag")
@@ -86,7 +91,7 @@ class TestVersion(unittest.TestCase):
     """
     
     # checks conversion with various numbers of arguments
-    
+    self.assert_string_matches("0.1.2.3-tag (git-7dcd105be34a4f44)")
     self.assert_string_matches("0.1.2.3-tag")
     self.assert_string_matches("0.1.2.3")
     self.assert_string_matches("0.1.2")

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits