X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/fdf4cb43a1c8133e013fd8ca2d1a5753ea048c90..fff9bce57321720677a897e3c811538eea6a9cb6:/stgit/commands/common.py diff --git a/stgit/commands/common.py b/stgit/commands/common.py index a4b5a87..836884c 100644 --- a/stgit/commands/common.py +++ b/stgit/commands/common.py @@ -233,3 +233,13 @@ def name_email_date(address): raise CmdException, 'Incorrect "name date" string: %s' % address return str_list[0] + +def make_patch_name(msg): + """Return a string to be used as a patch name. This is generated + from the top line of the string passed as argument. + """ + if not msg: + return None + + subject_line = msg.lstrip().split('\n', 1)[0] + return re.sub('[\W]+', '-', subject_line).strip('-')