From bbb7597cfec371c10dd8d59909f4bf1309d77f30 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Thu, 8 Dec 2022 23:09:26 +0300 Subject: [PATCH] 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: (cherry picked from commit 52cd87ea16f05fc3cc87be9315cd2d2e6dc9850d) --- .pick_status.json | 2 +- bin/gen_release_notes.py | 6 +++++- bin/gen_release_notes_test.py | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 27b5acf..aef9988 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -3919,7 +3919,7 @@ "description": "bin/gen_release_notes.py: don't fail if \"Closes\" refers to an MR", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/bin/gen_release_notes.py b/bin/gen_release_notes.py index 889c0a4..b7651d2 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 114b994..b8a5e38 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(), '')) -- 2.7.4