handle versions containing epochs
authorGuido Guenther <agx@sigxcpu.org>
Sun, 7 Oct 2007 11:53:46 +0000 (13:53 +0200)
committerGuido Guenther <agx@sigxcpu.org>
Sun, 7 Oct 2007 11:53:46 +0000 (13:53 +0200)
git-dch

diff --git a/git-dch b/git-dch
index 646378528eedf9bff7f5576768f293415f224203..10d27387a071c4e7fa900e6a0dcf7e0b10f1391f 100755 (executable)
--- a/git-dch
+++ b/git-dch
@@ -78,11 +78,15 @@ def head_commit():
 def snapshot_version(version):
     """
     get the current release and snapshot version
-    @FIXME: this causes trouble with epochs
+    Format is <debian-version>~<release>.gbp<short-commit-id>
     """
     try:
-        (release, suffix) = version.split('~', 1)
-        snapshot = int(suffix.split('.',1)[0])
+        (release, suffix) = version.rsplit('~', 1)
+        (snapshot, commit)  = suffix.split('.', 1)
+        if not commit.startswith('gbp'):
+            raise ValueError
+        else:
+            snapshot = int(snapshot)
     except ValueError: # not a snapshot release
         release = version
         snapshot = 0