[StGIT PATCH 2/5] Generate patch names of more uniform length

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Karl Hasselström <kha@xxxxxxxxxxx>

Cut the generated patch name at 30 characters after getting rid of
unwanted characters, not before. This gives patch names of more
uniform length, since consecutive unwanted characters were replaced by
a single dash.

Signed-off-by: Karl Hasselström <kha@xxxxxxxxxxx>
---

 stgit/utils.py |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/stgit/utils.py b/stgit/utils.py
index 18198c0..3612a4b 100644
--- a/stgit/utils.py
+++ b/stgit/utils.py
@@ -175,13 +175,13 @@ def call_editor(filename):
 
 def patch_name_from_msg(msg):
     """Return a string to be used as a patch name. This is generated
-    from the first 30 characters of the top line of the string passed
-    as argument."""
+    from the top line of the string passed as argument, and is at most
+    30 characters long."""
     if not msg:
         return None
 
-    subject_line = msg[:30].lstrip().split('\n', 1)[0].lower()
-    return re.sub('[\W]+', '-', subject_line).strip('-')
+    subject_line = msg.split('\n', 1)[0].lstrip().lower()
+    return re.sub('[\W]+', '-', subject_line).strip('-')[:30]
 
 def make_patch_name(msg, unacceptable, default_name = 'patch',
                     alternative = True):

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux