From 94628a8fbf32d72bfb0dd9cf10013605d89ca2c3 Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Thu, 17 Apr 2025 16:42:58 +0200 Subject: [PATCH] pick-ui: make `Backport-to: 25.0` backport to 25.0 *and more recent release branches* It is what developers expect, so make the code match it. Part-of: (cherry picked from commit c37a468a8a109cbaece70760fd748fc838185b88) --- .pick_status.json | 2 +- bin/pick/core.py | 4 +++- bin/pick/core_test.py | 11 +++++++++++ docs/submittingpatches.rst | 4 +++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 9a63017f56d..2d2f7720957 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1704,7 +1704,7 @@ "description": "pick-ui: make `Backport-to: 25.0` backport to 25.0 *and more recent release branches*", "nominated": false, "nomination_type": 0, - "resolution": 4, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/bin/pick/core.py b/bin/pick/core.py index 25610c4c804..8fa1098dacc 100644 --- a/bin/pick/core.py +++ b/bin/pick/core.py @@ -29,6 +29,7 @@ import subprocess import typing import attr +from packaging.version import Version if typing.TYPE_CHECKING: from .ui import UI @@ -294,7 +295,8 @@ async def resolve_nomination(commit: 'Commit', version: str) -> 'Commit': if backport_to := IS_BACKPORT.findall(commit_message): for match in backport_to: - if version in match: + if any(Version(version) >= Version(backport_version) + for backport_version in match if backport_version != ''): commit.nominated = True commit.nomination_type = NominationType.BACKPORT return commit diff --git a/bin/pick/core_test.py b/bin/pick/core_test.py index f1abadf0f56..53b89f2c0bd 100644 --- a/bin/pick/core_test.py +++ b/bin/pick/core_test.py @@ -405,6 +405,17 @@ class TestResolveNomination: assert c.nominated assert c.nomination_type is core.NominationType.BACKPORT + @pytest.mark.asyncio + async def test_backport_is_nominated_after(self): + s = self.FakeSubprocess(b'Backport-to: 16.2') + c = core.Commit('abcdef1234567890', 'a commit') + + with mock.patch('bin.pick.core.asyncio.create_subprocess_exec', s.mock): + await core.resolve_nomination(c, '16.3') + + assert c.nominated + assert c.nomination_type is core.NominationType.BACKPORT + @pytest.mark.asyncio async def test_backport_is_not_nominated(self): s = self.FakeSubprocess(b'Backport-to: 16.2') diff --git a/docs/submittingpatches.rst b/docs/submittingpatches.rst index b5346303773..d13bffe80fa 100644 --- a/docs/submittingpatches.rst +++ b/docs/submittingpatches.rst @@ -136,7 +136,9 @@ following example:: Backport-to: 21.0 -Multiple ``Backport-to:`` lines are allowed. +This will backport the commit to the 21.0 branch, as well as any more recent +stable branch. Multiple ``Backport-to:`` lines are allowed, but only the +lowest number mentioned actually matters, so for clarity, please only use one. The last option is deprecated and mostly here for historical reasons dating back to when patch submission was done via emails: using a ``Cc:``