diff --git a/presubmit_support.py b/presubmit_support.py index 178e0e988..fdbbc7207 100755 --- a/presubmit_support.py +++ b/presubmit_support.py @@ -1032,7 +1032,11 @@ class Change(object): def BugsFromDescription(self): """Returns all bugs referenced in the commit description.""" tags = [b.strip() for b in self.tags.get('BUG', '').split(',') if b.strip()] - footers = git_footers.parse_footers(self._full_description).get('Bug', []) + footers = [] + unsplit_footers = git_footers.parse_footers(self._full_description).get( + 'Bug', []) + for unsplit_footer in unsplit_footers: + footers += [b.strip() for b in unsplit_footer.split(',')] return sorted(set(tags + footers)) def ReviewersFromDescription(self): diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index 899e04526..a60484107 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -1553,12 +1553,19 @@ class ChangeUnittest(PresubmitTestsBase): self.assertEquals('WHIZ=bang\nbar\nFOO=baz', change.FullDescriptionText()) self.assertEquals({'WHIZ': 'bang', 'FOO': 'baz'}, change.tags) - def testBugsFromDescription(self): + def testBugsFromDescription_MixedTagsAndFooters(self): change = presubmit.Change( - '', 'foo\nBUG=2,1\n\nChange-Id: asdf\nBug: 3', + '', 'foo\nBUG=2,1\n\nChange-Id: asdf\nBug: 3, 6', self.fake_root_dir, [], 0, 0, '') - self.assertEquals(['1', '2', '3'], change.BugsFromDescription()) - self.assertEquals('1,2,3', change.BUG) + self.assertEquals(['1', '2', '3', '6'], change.BugsFromDescription()) + self.assertEquals('1,2,3,6', change.BUG) + + def testBugsFromDescription_MultipleFooters(self): + change = presubmit.Change( + '', 'foo\n\nChange-Id: asdf\nBug: 1\nBug:4, 6', + self.fake_root_dir, [], 0, 0, '') + self.assertEquals(['1', '4', '6'], change.BugsFromDescription()) + self.assertEquals('1,4,6', change.BUG) def testReviewersFromDescription(self): change = presubmit.Change(