bin/gen_release_notes.py: don't fail if "Closes" refers to an MR

Sometimes a tag "Closes:" in a commit may refer to a merge request
instead of an issue. Examples of such commits:

    34319c7d84 "ci/freedreno: disable antichambers trace"
    998122d9c2 "mesa: fix GL_INVALID_OPERATION in glEGLImageTargetTexStorageEXT"

Avoid failing on these by explicitly checking that the URL refers to an
issue

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-08 23:09:26 +03:00
parent 334123a908
commit 52cd87ea16
2 changed files with 21 additions and 1 deletions

View File

@@ -195,7 +195,11 @@ async def parse_issues(commits: str) -> typing.List[str]:
for line in reversed(out):
if line.startswith('Closes:'):
bug = line.lstrip('Closes:').strip()
if bug.startswith('https://gitlab.freedesktop.org/mesa/mesa'):
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:

View File

@@ -148,6 +148,22 @@ async def test_gather_commits():
''',
['3456', '3457', '3458'],
),
(
'''\
Without /-/
Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/36
''',
['36'],
),
(
'''\
Ignore merge_requests
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20241
''',
[],
),
])
async def test_parse_issues(content: str, bugs: typing.List[str]) -> None:
mock_com = mock.AsyncMock(return_value=(textwrap.dedent(content).encode(), ''))