bin/gen_release_notes.py: parse "Fixes" tags as well as "Closes"

Some commits refer to bugs being fixed with "Fixes" tag. Example of one:

    e13d53e1fdb 'Revert "glx/dri: Fix DRI drawable release at MakeCurrent time"'

Parse this tag as well.

Cc: mesa-stable
Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
Reviewed-by: Eric Engestrom <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20241>
This commit is contained in:
Konstantin Kharlamov
2022-12-09 19:16:22 +03:00
parent 52cd87ea16
commit e67578a264
2 changed files with 31 additions and 14 deletions

View File

@@ -175,7 +175,7 @@ inliner = Inliner();
async def gather_commits(version: str) -> str: async def gather_commits(version: str) -> str:
p = await asyncio.create_subprocess_exec( 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) stdout=asyncio.subprocess.PIPE)
out, _ = await p.communicate() out, _ = await p.communicate()
assert p.returncode == 0, f"git log didn't work: {version}" 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') out = _out.decode().split('\n')
for line in reversed(out): for line in reversed(out):
if line.startswith('Closes:'): if not line.startswith(('Closes:', 'Fixes:')):
bug = line.lstrip('Closes:').strip() continue
if (bug.startswith('https://gitlab.freedesktop.org/mesa/mesa') bug = line.split(':', 1)[1].strip()
# Avoid parsing "merge_requests" URL. Note that a valid issue if (bug.startswith('https://gitlab.freedesktop.org/mesa/mesa')
# URL may or may not contain the "/-/" text, so we check if # Avoid parsing "merge_requests" URL. Note that a valid issue
# the word "issues" is contained in URL. # URL may or may not contain the "/-/" text, so we check if
and '/issues' in bug): # the word "issues" is contained in URL.
# This means we have a bug in the form "Closes: https://..." and '/issues' in bug):
issues.append(os.path.basename(urllib.parse.urlparse(bug).path)) # This means we have a bug in the form "Closes: https://..."
elif ',' in bug: issues.append(os.path.basename(urllib.parse.urlparse(bug).path))
issues.extend([b.strip().lstrip('#') for b in bug.split(',')]) elif ',' in bug:
elif bug.startswith('#'): multiple_bugs = [b.strip().lstrip('#') for b in bug.split(',')]
issues.append(bug.lstrip('#')) 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 return issues

View File

@@ -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: async def test_parse_issues(content: str, bugs: typing.List[str]) -> None:
mock_com = mock.AsyncMock(return_value=(textwrap.dedent(content).encode(), '')) mock_com = mock.AsyncMock(return_value=(textwrap.dedent(content).encode(), ''))