chiark / gitweb /
Make the maximum patch name length configurable
[stgit] / stgit / utils.py
index 38dd474e7643e2d91acd69ade706594f897190c4..02e98e99645217a7572dcecbfb2c28eccd093907 100644 (file)
@@ -190,13 +190,16 @@ 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 top line of the string passed as argument, and is at most
-    30 characters long."""
+    from the top line of the string passed as argument."""
     if not msg:
         return None
 
+    name_len = config.get('stgit.namelength')
+    if not name_len:
+        name_len = 30
+
     subject_line = msg.split('\n', 1)[0].lstrip().lower()
-    return re.sub('[\W]+', '-', subject_line).strip('-')[:30]
+    return re.sub('[\W]+', '-', subject_line).strip('-')[:name_len]
 
 def make_patch_name(msg, unacceptable, default_name = 'patch'):
     """Return a patch name generated from the given commit message,