From e7b2eda39db915c8516ac13a3ac9765e73b15455 Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Fri, 21 Mar 2025 12:26:20 +0100 Subject: [PATCH] pick-ui: fix parsing of multiple `backport-to:` lines Cc: mesa-stable Part-of: --- bin/pick/core.py | 11 ++++++----- bin/pick/core_test.py | 27 ++++++++++++++++++--------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/bin/pick/core.py b/bin/pick/core.py index 48c3bf6b28e..25610c4c804 100644 --- a/bin/pick/core.py +++ b/bin/pick/core.py @@ -292,11 +292,12 @@ async def resolve_nomination(commit: 'Commit', version: str) -> 'Commit': commit.nominated = True return commit - if backport_to := IS_BACKPORT.search(commit_message): - if version in backport_to.groups(): - commit.nominated = True - commit.nomination_type = NominationType.BACKPORT - return commit + if backport_to := IS_BACKPORT.findall(commit_message): + for match in backport_to: + if version in match: + commit.nominated = True + commit.nomination_type = NominationType.BACKPORT + return commit if cc_to := IS_CC.search(commit_message): if cc_to.groups() == (None, None) or version in cc_to.groups(): diff --git a/bin/pick/core_test.py b/bin/pick/core_test.py index a496913ff9e..f1abadf0f56 100644 --- a/bin/pick/core_test.py +++ b/bin/pick/core_test.py @@ -262,9 +262,8 @@ class TestRE: Reviewed-by: Bas Nieuwenhuizen """) - backport_to = core.IS_BACKPORT.search(message) - assert backport_to is not None - assert backport_to.groups() == ('19.2', None) + backport_to = core.IS_BACKPORT.findall(message) + assert backport_to == [('19.2', '')] def test_multiple_release_space(self): """Tests commit with more than one branch specified""" @@ -278,9 +277,8 @@ class TestRE: Reviewed-by: Pierre-Eric Pelloux-Prayer """) - backport_to = core.IS_BACKPORT.search(message) - assert backport_to is not None - assert backport_to.groups() == ('19.1', '19.2') + backport_to = core.IS_BACKPORT.findall(message) + assert backport_to == [('19.1', '19.2')] def test_multiple_release_comma(self): """Tests commit with more than one branch specified""" @@ -294,9 +292,20 @@ class TestRE: Reviewed-by: Pierre-Eric Pelloux-Prayer """) - backport_to = core.IS_BACKPORT.search(message) - assert backport_to is not None - assert backport_to.groups() == ('19.1', '19.2') + backport_to = core.IS_BACKPORT.findall(message) + assert backport_to == [('19.1', '19.2')] + + def test_multiple_release_lines(self): + """Tests commit with more than one branch specified in mulitple tags""" + message = textwrap.dedent("""\ + commit title + + Backport-to: 19.0 + Backport-to: 19.1, 19.2 + """) + + backport_to = core.IS_BACKPORT.findall(message) + assert backport_to == [('19.0', ''), ('19.1', '19.2')] class TestResolveNomination: