Commit 6295404c authored by Dan Beam's avatar Dan Beam Committed by Commit Bot

Support "Fixed:" syntax in BugsFromDescription()

Bug: monorail:4470
Change-Id: I2a1dcc1fe00d29f9d058152c15c75f8f904c354a
Recipe-Nontrivial-Roll: chromiumos
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1836601
Auto-Submit: Dan Beam <dbeam@chromium.org>
Commit-Queue: Dan Beam <dbeam@chromium.org>
Reviewed-by: 's avatarAaron Gable <agable@chromium.org>
parent d73aef15
......@@ -1049,8 +1049,8 @@ class Change(object):
"""Returns all bugs referenced in the commit description."""
tags = [b.strip() for b in self.tags.get('BUG', '').split(',') if b.strip()]
footers = []
unsplit_footers = git_footers.parse_footers(self._full_description).get(
'Bug', [])
parsed = git_footers.parse_footers(self._full_description)
unsplit_footers = parsed.get('Bug', []) + parsed.get('Fixed', [])
for unsplit_footer in unsplit_footers:
footers += [b.strip() for b in unsplit_footer.split(',')]
return sorted(set(tags + footers))
......
......@@ -1375,6 +1375,13 @@ class ChangeUnittest(PresubmitTestsBase):
self.assertEqual('WHIZ=bang\nbar\nFOO=baz', change.FullDescriptionText())
self.assertEqual({'WHIZ': 'bang', 'FOO': 'baz'}, change.tags)
def testBugFromDescription_FixedAndBugGetDeduped(self):
change = presubmit.Change(
'', 'foo\n\nChange-Id: asdf\nBug: 1, 2\nFixed:2, 1 ',
self.fake_root_dir, [], 0, 0, '')
self.assertEqual(['1', '2'], change.BugsFromDescription())
self.assertEqual('1,2', change.BUG)
def testBugsFromDescription_MixedTagsAndFooters(self):
change = presubmit.Change(
'', 'foo\nBUG=2,1\n\nChange-Id: asdf\nBug: 3, 6',
......@@ -1384,10 +1391,17 @@ class ChangeUnittest(PresubmitTestsBase):
def testBugsFromDescription_MultipleFooters(self):
change = presubmit.Change(
'', 'foo\n\nChange-Id: asdf\nBug: 1\nBug:4, 6',
'', 'foo\n\nChange-Id: asdf\nBug: 1\nBug:4, 6\nFixed: 7',
self.fake_root_dir, [], 0, 0, '')
self.assertEqual(['1', '4', '6', '7'], change.BugsFromDescription())
self.assertEqual('1,4,6,7', change.BUG)
def testBugFromDescription_OnlyFixed(self):
change = presubmit.Change(
'', 'foo\n\nChange-Id: asdf\nFixed:1, 2',
self.fake_root_dir, [], 0, 0, '')
self.assertEqual(['1', '4', '6'], change.BugsFromDescription())
self.assertEqual('1,4,6', change.BUG)
self.assertEqual(['1', '2'], change.BugsFromDescription())
self.assertEqual('1,2', change.BUG)
def testReviewersFromDescription(self):
change = presubmit.Change(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment