diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2016-08-08 16:48:32 +0100 |
---|---|---|
committer | Thibault Saunier <tsaunier@gnome.org> | 2016-08-09 14:37:39 -0400 |
commit | 80f3b4c34f442d737c376f18a15b9388dcbb3aed (patch) | |
tree | de1f54d59a66f71e5b5114bff61e2728c707e297 | |
parent | e0cbfcf63097f49ade53b9e1078a54fecc19fbc0 (diff) |
git-phab: Search for blacklisted fields in attach commit messages
As well as when landing a commit, search for blacklisted fields when
initially attaching the commit to Phabricator, otherwise attaching a
comment with a subject like ‘tests: Add more tests’ will fail.
Signed-off-by: Philip Withnall <philip.withnall@collabora.co.uk>
Reviewed-by: Thibault Saunier <tsaunier@gnome.org>
Differential Revision: https://phabricator.freedesktop.org/D1255
-rwxr-xr-x | git-phab | 34 |
1 files changed, 19 insertions, 15 deletions
@@ -649,8 +649,7 @@ Paste API Token from that page and press <enter>: """ % self.phabricator_uri) """ return msg.split('\n---\n', 1)[0] - def format_commit_msg(self, subject, body, git_fields, phab_fields, - ask=False): + def format_field(self, field, ask=False): # This is the list of fields phabricator will search by default in # commit message, case insensitive. It will confuse phabricator's # parser if they appear in the subject or body of the commit message. @@ -662,22 +661,27 @@ Paste API Token from that page and press <enter>: """ % self.phabricator_uri) 'differential revision:', 'conflicts:', 'git-svn-id:', 'auditors:'] - subject = subject.strip() - body = '\n'.join(body).strip() - fields = '\n'.join(git_fields + phab_fields).strip() - for header in blacklist: header_ = header[:-1] + '_:' - s = re.sub(re.escape(header), header_, subject, flags=re.I) - b = re.sub(re.escape(header), header_, body, flags=re.I) - if (s != subject or b != body) and ( + f = re.sub(re.escape(header), header_, field, flags=re.I) + if (f != field) and ( not ask or self.prompt( "Commit message contains '%s'.\n" - "It could confuse phabricator's parser.\n" - "Do you want to prefix is with an underscore?" % + "It could confuse Phabricator's parser.\n" + "Do you want to suffix it with an underscore?" % header)): - subject = s - body = b + field = f + + return field + + def format_commit_msg(self, subject, body, git_fields, phab_fields, + ask=False): + subject = subject.strip() + body = '\n'.join(body).strip() + fields = '\n'.join(git_fields + phab_fields).strip() + + subject = self.format_field(subject, ask) + body = self.format_field(body, ask) return '\n\n'.join([subject, body, fields]) @@ -998,11 +1002,11 @@ Paste API Token from that page and press <enter>: """ % self.phabricator_uri) arc_message = arc_message.replace( "<<Replace this line with your Revision Title>>", - subject) + self.format_field(subject, True)) if summary != '': arc_message = arc_message.replace( "Summary: ", - "Summary:\n" + summary) + "Summary:\n" + self.format_field(summary, True)) if self.reviewers: arc_message = arc_message.replace( |