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:``