diff options
author | Catalin Marinas <catalin.marinas@gmail.com> | 2010-10-22 16:44:13 +0100 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@gmail.com> | 2010-10-22 16:44:13 +0100 |
commit | 3f47bf3a0d06007bd9ee2fa2c81bef8761b328a4 (patch) | |
tree | 216a1ef365c9f2046386f6e8b24f0c45877c5327 | |
parent | 2034b19ee1787725164e695cffa6d50384ef8cb1 (diff) | |
download | stgit-3f47bf3a0d06007bd9ee2fa2c81bef8761b328a4.tar.gz |
Do not truncate the last word when creating patch names
The automatically generated patch names are truncated to
stgit.namelength but this was truncating the final words.
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
-rw-r--r-- | stgit/utils.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/stgit/utils.py b/stgit/utils.py index 2955adf..5599f7e 100644 --- a/stgit/utils.py +++ b/stgit/utils.py @@ -230,7 +230,17 @@ def patch_name_from_msg(msg): name_len = 30 subject_line = msg.split('\n', 1)[0].lstrip().lower() - return re.sub('[\W]+', '-', subject_line)[:name_len].strip('-') + words = re.sub('[\W]+', ' ', subject_line).split() + + # use loop to avoid truncating the last name + name = words and words[0] or 'unknown' + for word in words[1:]: + new = name + '-' + word + if len(new) > name_len: + break + name = new + + return name def make_patch_name(msg, unacceptable, default_name = 'patch'): """Return a patch name generated from the given commit message, |