mozautomation: only strip MozReview-Commit-ID from commit descriptions (
bug 1269649) r?gps
Instead of removing anything that may be a meta tag, just remove known tags.
MozReview-Commit-ID: Dqy7J4PLSmq
--- a/pylib/mozautomation/mozautomation/commitparser.py
+++ b/pylib/mozautomation/mozautomation/commitparser.py
@@ -57,17 +57,19 @@ BACKOUT_RE = re.compile('^back\s?out (?P
SHORT_RE = re.compile('^[0-9a-f]{12}$', re.I)
DIGIT_RE = re.compile('#?\d+')
BACK_OUT_MULTIPLE_RE = re.compile(
'^back(?:ed)? out \d+ changesets \(bug ', re.I)
-METADATA_RE = re.compile('^[a-zA-Z-]+: ')
+# Strip out a white-list of metadata prefixes.
+# Currently just MozReview-Commit-ID
+METADATA_RE = re.compile('^MozReview-Commit-ID: ')
def parse_bugs(s):
bugs = [int(m[1]) for m in BUG_RE.findall(s)]
return [bug for bug in bugs if bug < 100000000]
def filter_reviewers(s):
--- a/pylib/mozautomation/tests/test_commitparser.py
+++ b/pylib/mozautomation/tests/test_commitparser.py
@@ -360,17 +360,17 @@ class TestBugParsing(unittest.TestCase):
self.assertEqual(strip_commit_metadata('foo\n\nbar'), 'foo\n\nbar')
self.assertEqual(strip_commit_metadata(
'Bug 1 - foo\n\nMozReview-Commit-ID: abcdef'),
'Bug 1 - foo')
self.assertEqual(strip_commit_metadata(
'Bug 1 - foo\n\nMore description\n\nFoo-Bar: baz\n\n'),
- 'Bug 1 - foo\n\nMore description')
+ 'Bug 1 - foo\n\nMore description\n\nFoo-Bar: baz')
self.assertEqual(strip_commit_metadata(
'Bug 1 - foo\n\nMozReview-Commit-ID: abcdef\n\nTrailing desc'),
'Bug 1 - foo\n\n\nTrailing desc')
# unicode in should get unicode out
res = strip_commit_metadata(u'foo\n\nbar')
self.assertEqual(res, u'foo\n\nbar')