diff --git a/bin/gen_release_notes.py b/bin/gen_release_notes.py index b7651d2935e..54af4970157 100755 --- a/bin/gen_release_notes.py +++ b/bin/gen_release_notes.py @@ -175,7 +175,7 @@ inliner = Inliner(); async def gather_commits(version: str) -> str: p = await asyncio.create_subprocess_exec( - 'git', 'log', '--oneline', f'mesa-{version}..', '--grep', r'Closes: \(https\|#\).*', + 'git', 'log', '--oneline', f'mesa-{version}..', '--grep', r'\(Closes\|Fixes\): \(https\|#\).*', stdout=asyncio.subprocess.PIPE) out, _ = await p.communicate() assert p.returncode == 0, f"git log didn't work: {version}" @@ -193,19 +193,24 @@ async def parse_issues(commits: str) -> typing.List[str]: out = _out.decode().split('\n') for line in reversed(out): - if line.startswith('Closes:'): - bug = line.lstrip('Closes:').strip() - if (bug.startswith('https://gitlab.freedesktop.org/mesa/mesa') - # Avoid parsing "merge_requests" URL. Note that a valid issue - # URL may or may not contain the "/-/" text, so we check if - # the word "issues" is contained in URL. - and '/issues' in bug): - # 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('#')) + if not line.startswith(('Closes:', 'Fixes:')): + continue + bug = line.split(':', 1)[1].strip() + if (bug.startswith('https://gitlab.freedesktop.org/mesa/mesa') + # Avoid parsing "merge_requests" URL. Note that a valid issue + # URL may or may not contain the "/-/" text, so we check if + # the word "issues" is contained in URL. + and '/issues' in bug): + # This means we have a bug in the form "Closes: https://..." + issues.append(os.path.basename(urllib.parse.urlparse(bug).path)) + elif ',' in bug: + multiple_bugs = [b.strip().lstrip('#') for b in bug.split(',')] + if not all(b.isdigit() for b in multiple_bugs): + # this is likely a "Fixes" tag that refers to a commit name + continue + issues.extend(multiple_bugs) + 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 b8a5e386f3e..8ab76e451e6 100644 --- a/bin/gen_release_notes_test.py +++ b/bin/gen_release_notes_test.py @@ -164,6 +164,18 @@ async def test_gather_commits(): ''', [], ), + ( + '''\ + Parse "Fixes:" tag too + + Fixes: https://gitlab.freedesktop.org/mesa/mesa/issues/36 + Fixes: 142565a3bc2 + Fixes: 142565a3bc2 ("docs: do something very useful") + Fixes: 142565a3bc2 ("docs: fix #1234, have a comma") + Fixes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/37 + ''', + ['36', '37'], + ), ]) async def test_parse_issues(content: str, bugs: typing.List[str]) -> None: mock_com = mock.AsyncMock(return_value=(textwrap.dedent(content).encode(), ''))