diff --git a/presubmit_support.py b/presubmit_support.py index 486914ddd..672f5e736 100755 --- a/presubmit_support.py +++ b/presubmit_support.py @@ -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)) diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index 3a148ab0f..a574ef6da 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -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(