From da00a11bf28f9b9898efa1e6184fa27ea8277a94 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 4 Aug 2021 11:37:12 -0700 Subject: [PATCH] bin/gen_release_notes: Fix commits with multiple Closes: Currently we'd only handle the last one, not all of them. Which is clearely not correct. Reviewed-by: Eric Engestrom Part-of: --- bin/gen_release_notes.py | 16 +++++++--------- bin/gen_release_notes_test.py | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/bin/gen_release_notes.py b/bin/gen_release_notes.py index bfc65ca92b7..9b14c908bb5 100755 --- a/bin/gen_release_notes.py +++ b/bin/gen_release_notes.py @@ -195,15 +195,13 @@ async def parse_issues(commits: str) -> typing.List[str]: for line in reversed(out): if line.startswith('Closes:'): bug = line.lstrip('Closes:').strip() - break - else: - raise Exception('No closes found?') - - if bug.startswith('https://gitlab.freedesktop.org/mesa/mesa'): - # This means we have a bug in the form "Closes: https://..." - issues.append(os.path.basename(urllib.parse.urlparse(bug).path)) - elif bug.startswith('#'): - issues.append(bug.lstrip('#')) + if bug.startswith('https://gitlab.freedesktop.org/mesa/mesa'): + # This means we have a bug in the form "Closes: https://..." + issues.append(os.path.basename(urllib.parse.urlparse(bug).path)) + elif ',' in bug: + issues.extend([b.strip().lstrip('#') for b in bug.split(',')]) + elif bug.startswith('#'): + issues.append(bug.lstrip('#')) return issues diff --git a/bin/gen_release_notes_test.py b/bin/gen_release_notes_test.py index 194fbc745ac..114b99469fe 100644 --- a/bin/gen_release_notes_test.py +++ b/bin/gen_release_notes_test.py @@ -117,6 +117,37 @@ async def test_gather_commits(): ''', [], ), + + # Test multiple issues on one line + ( + '''\ + Fix many bugs + + Closes: #1, #2 + ''', + ['1', '2'], + ), + + # Test multiple closes + ( + '''\ + Fix many bugs + + Closes: #1 + Closes: #2 + ''', + ['1', '2'], + ), + ( + '''\ + With long form + + Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3456 + Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3457 + Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3458 + ''', + ['3456', '3457', '3458'], + ), ]) async def test_parse_issues(content: str, bugs: typing.List[str]) -> None: mock_com = mock.AsyncMock(return_value=(textwrap.dedent(content).encode(), '')) @@ -127,4 +158,4 @@ async def test_parse_issues(content: str, bugs: typing.List[str]) -> None: with mock.patch('bin.gen_release_notes.asyncio.create_subprocess_exec', mock_exec), \ mock.patch('bin.gen_release_notes.gather_commits', mock.AsyncMock(return_value='sha\n')): ids = await parse_issues('1234 not used') - assert ids == bugs + assert set(ids) == set(bugs)