X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/9060d4205a9093a8f3c8ff958eff4c64107077cc..c4f99b6c10c3bc2558fe8d9050bcaaa3efb830b0:/stgit/utils.py diff --git a/stgit/utils.py b/stgit/utils.py index 18198c0..fbfe748 100644 --- a/stgit/utils.py +++ b/stgit/utils.py @@ -175,23 +175,22 @@ 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): +def make_patch_name(msg, unacceptable, default_name = 'patch'): """Return a patch name generated from the given commit message, guaranteed to make unacceptable(name) be false. If the commit message is empty, base the name on default_name instead.""" patchname = patch_name_from_msg(msg) if not patchname: patchname = default_name - if alternative and unacceptable(patchname): + if unacceptable(patchname): suffix = 0 while unacceptable('%s-%d' % (patchname, suffix)): suffix += 1