From 52cd87ea16f05fc3cc87be9315cd2d2e6dc9850d Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Thu, 8 Dec 2022 23:09:26 +0300 Subject: 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 Reviewed-by: Eric Engestrom Part-of: --- bin/gen_release_notes.py | 6 +++++- bin/gen_release_notes_test.py | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/bin/gen_release_notes.py b/bin/gen_release_notes.py index 889c0a43654..b7651d2935e 100755 --- a/bin/gen_release_notes.py +++ b/bin/gen_release_notes.py @@ -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: diff --git a/bin/gen_release_notes_test.py b/bin/gen_release_notes_test.py index 114b99469fe..b8a5e386f3e 100644 --- a/bin/gen_release_notes_test.py +++ b/bin/gen_release_notes_test.py @@ -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(), '')) -- cgit v1.2.1