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:
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

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:
mock_com = mock.AsyncMock(return_value=(textwrap.dedent(content).encode(), ''))