Still assumes all tags appear at the bottom without extra spaces. Extends the known tags to include "Change-Id:", and still requires a new line before the first tag (so that it won't count if the commit message starts with a tag as the only thing). Does not generalize to all "tag-like" things, but will be re-used to support insertion of gerrit style Change-Ids.
Signed-off-by: Jacob Keller <[email protected]> --- stgit/utils.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/stgit/utils.py b/stgit/utils.py index 0b66be339ff6..225aa3b2d014 100644 --- a/stgit/utils.py +++ b/stgit/utils.py @@ -265,6 +265,15 @@ def all(bools): return False return True +def split_desc_and_tags(desc): + # Be sure to use regex-safe characters here + tags = ['Cc:', 'Change-Id:' 'Acked-by:', 'Reported-by:', 'Reviewed-by:', + 'Reviewed-on:', 'Signed-off-by:', 'Suggested-by:', 'Tested-by:', ] + + regex = '(%s)' % '|'.join(['\n%s' % tag for tag in tags]) + + return re.split(regex, desc, maxsplit=1) + def add_sign_line(desc, sign_str, name, email): if not sign_str: return desc @@ -272,9 +281,10 @@ def add_sign_line(desc, sign_str, name, email): if sign_str in desc: return desc desc = desc.rstrip() - tags = ['\nCc:', '\nSigned-off-by:', '\nAcked-by:', '\nReported-by', - '\nTested-by:', '\nReviewed-by:', '\nSuggested-by:'] - if not any(s in desc for s in tags): + split = split_desc_and_tags(desc) + + # Put the signoff at end + if len(split) == 1: desc = desc + '\n' return '%s\n%s\n' % (desc, sign_str) -- 2.6.1.264.gbab76a9 _______________________________________________ stgit-users mailing list [email protected] https://mail.gna.org/listinfo/stgit-users
