From 1b814c72ae60604d2073d52b5c89ccbd4cee96e5 Mon Sep 17 00:00:00 2001 Message-Id: <1b814c72ae60604d2073d52b5c89ccbd4cee96e5.1746540250.git.mdw@distorted.org.uk> From: Mark Wooding Date: Wed, 29 Aug 2007 11:52:59 +0100 Subject: [PATCH] Make the maximum patch name length configurable Organization: Straylight/Edgeware From: Catalin Marinas The config variable is stgit.namelenth Signed-off-by: Catalin Marinas --- examples/gitconfig | 3 +++ stgit/utils.py | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/gitconfig b/examples/gitconfig index f1c653e..f181f82 100644 --- a/examples/gitconfig +++ b/examples/gitconfig @@ -94,6 +94,9 @@ # current one by the 'series --short' command #shortnr = 5 + # The maximum length of an automatically generated patch name + #namelenth = 30 + [mail "alias"] # E-mail aliases used with the 'mail' command git = git@vger.kernel.org diff --git a/stgit/utils.py b/stgit/utils.py index 38dd474..02e98e9 100644 --- a/stgit/utils.py +++ b/stgit/utils.py @@ -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, -- [mdw]