scripts/pq: handle patches without filename extension
authorGuido Günther <agx@sigxcpu.org>
Sun, 18 Dec 2011 12:41:13 +0000 (13:41 +0100)
committerGuido Günther <agx@sigxcpu.org>
Sun, 18 Dec 2011 12:44:26 +0000 (13:44 +0100)
Don't fail if patches don't have a proper patch header and filename
extensions (like in the heimdal package)

gbp/scripts/pq.py

index 5b7f32c..e8e9497 100644 (file)
@@ -304,12 +304,17 @@ def get_patch_subject_from_filename(patch):
     'foo'
     >>> get_patch_subject('debian/patches/foo.bar')
     'foo.bar'
+    >>> get_patch_subject('debian/patches/foo')
+    'foo'
     """
     subject = os.path.basename(patch)
     # Strip of .diff or .patch from patch name
-    base, ext = subject.rsplit('.', 1)
-    if ext in [ 'diff', 'patch' ]:
-        subject = base
+    try:
+        base, ext = subject.rsplit('.', 1)
+        if ext in [ 'diff', 'patch' ]:
+            subject = base
+    except ValueError:
+        pass # No ext so keep subject as is
     return subject
 
 def apply_and_commit_patch(repo, patch, topic=None):