gbp-pq: Strip .patch and .diff
authorGuido Günther <agx@sigxcpu.org>
Mon, 24 Oct 2011 07:48:00 +0000 (09:48 +0200)
committerGuido Günther <agx@sigxcpu.org>
Mon, 24 Oct 2011 07:57:31 +0000 (09:57 +0200)
when importing patches without a subject

gbp-pq

diff --git a/gbp-pq b/gbp-pq
index 3c22df9..1b04642 100755 (executable)
--- a/gbp-pq
+++ b/gbp-pq
@@ -301,8 +301,13 @@ def apply_and_commit_patch(repo, patch, topic=None):
     """apply a single patch 'patch', add topic 'topic' and commit it"""
     header, body = get_mailinfo(patch)
 
+    # If we don't find a subject use the patch's name
     if not header.has_key('subject'):
         header['subject'] = os.path.basename(patch)
+        # Strip of .diff or .patch from patch name
+        base, ext = header['subject'].rsplit('.', 1)
+        if ext in [ 'diff', 'patch' ]:
+            header['subject'] = base
 
     if header.has_key('author') and header.has_key('email'):
         header['name'] = header['author']