From e42c5b86d0f7fccf3c3866b1452309ad65833b4b Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Mon, 18 Oct 2021 23:02:52 +0100 Subject: [PATCH] pick-ui: add `Backport-to: XX.Y` nomination Signed-off-by: Eric Engestrom Cc: mesa-stable Part-of: --- bin/pick/core.py | 9 ++++ bin/pick/core_test.py | 89 ++++++++++++++++++++++++++++++++++++++ docs/submittingpatches.rst | 15 +++++-- 3 files changed, 110 insertions(+), 3 deletions(-) diff --git a/bin/pick/core.py b/bin/pick/core.py index d7dfb12a117..cde058602c1 100644 --- a/bin/pick/core.py +++ b/bin/pick/core.py @@ -51,6 +51,8 @@ IS_FIX = re.compile(r'^\s*fixes:\s*([a-f0-9]{6,40})', flags=re.MULTILINE | re.IG IS_CC = re.compile(r'^\s*cc:\s*["\']?([0-9]{2}\.[0-9])?["\']?\s*["\']?([0-9]{2}\.[0-9])?["\']?\s*\ 'Commit': commit.nominated = True return commit + if backport_to := IS_BACKPORT.search(out): + if version in backport_to.groups(): + commit.nominated = True + commit.nomination_type = NominationType.BACKPORT + return commit + if cc_to := IS_CC.search(out): if cc_to.groups() == (None, None) or version in cc_to.groups(): commit.nominated = True diff --git a/bin/pick/core_test.py b/bin/pick/core_test.py index f2ac6ede1ce..d7579be71ac 100644 --- a/bin/pick/core_test.py +++ b/bin/pick/core_test.py @@ -236,6 +236,58 @@ class TestRE: assert revert_of is not None assert revert_of.group(1) == '2ca8629fa9b303e24783b76a7b3b0c2513e32fbd' + class TestBackportTo: + + def test_single_release(self): + """Tests commit meant for a single branch, ie, 19.1""" + message = textwrap.dedent("""\ + radv: fix DCC fast clear code for intensity formats + + This fixes a rendering issue with DiRT 4 on GFX10. Only GFX10 was + affected because intensity formats are different. + + Backport-to: 19.2 + Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/1923 + Signed-off-by: Samuel Pitoiset + Reviewed-by: Bas Nieuwenhuizen + """) + + backport_to = core.IS_BACKPORT.search(message) + assert backport_to is not None + assert backport_to.groups() == ('19.2', None) + + def test_multiple_release_space(self): + """Tests commit with more than one branch specified""" + message = textwrap.dedent("""\ + radeonsi: enable zerovram for Rocket League + + Fixes corruption on game startup. + Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/1888 + + Backport-to: 19.1 19.2 + 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') + + def test_multiple_release_comma(self): + """Tests commit with more than one branch specified""" + message = textwrap.dedent("""\ + radeonsi: enable zerovram for Rocket League + + Fixes corruption on game startup. + Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/1888 + + Backport-to: 19.1, 19.2 + 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') + class TestResolveNomination: @@ -323,6 +375,28 @@ class TestResolveNomination: assert not c.nominated assert c.nomination_type is None + @pytest.mark.asyncio + async def test_backport_is_nominated(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.2') + + 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') + c = core.Commit('abcdef1234567890', 'a commit') + + with mock.patch('bin.pick.core.asyncio.create_subprocess_exec', s.mock): + await core.resolve_nomination(c, '16.1') + + assert not c.nominated + assert c.nomination_type is None + @pytest.mark.asyncio async def test_revert_is_nominated(self): s = self.FakeSubprocess(b'This reverts commit 1234567890123456789012345678901234567890.') @@ -347,6 +421,21 @@ class TestResolveNomination: assert not c.nominated assert c.nomination_type is core.NominationType.REVERT + @pytest.mark.asyncio + async def test_is_fix_and_backport(self): + s = self.FakeSubprocess( + b'Fixes: 3d09bb390a39 (etnaviv: GC7000: State changes for HALTI3..5)\n' + b'Backport-to: 16.1' + ) + c = core.Commit('abcdef1234567890', 'a commit') + + with mock.patch('bin.pick.core.asyncio.create_subprocess_exec', s.mock): + with mock.patch('bin.pick.core.is_commit_in_branch', self.return_true): + await core.resolve_nomination(c, '16.1') + + assert c.nominated + assert c.nomination_type is core.NominationType.FIXES + @pytest.mark.asyncio async def test_is_fix_and_cc(self): s = self.FakeSubprocess( diff --git a/docs/submittingpatches.rst b/docs/submittingpatches.rst index 31f267a187d..dfed1fa2cdd 100644 --- a/docs/submittingpatches.rst +++ b/docs/submittingpatches.rst @@ -100,7 +100,7 @@ Patch formatting Acked-by: Joe Hacker - When updating a merge request add all the tags (``Acked-by:``, ``Reviewed-by:``, - ``Fixes:``, ``Cc: mesa-stable`` and/or other) to the commit messages. + ``Fixes:``, ``Backport-to:`` and/or other) to the commit messages. This provides reviewers with quick feedback if the patch has already been reviewed. @@ -131,8 +131,17 @@ is the preferred way to nominate a commit that should be backported. There are scripts that will figure out which releases to apply the patch to automatically, so you don't need to figure it out. -Alternatively, you may use a "CC:" tag. Here are some examples of such a -note:: +Alternatively, you may use the ``Backport-to:`` tag, as presented in the +following example:: + + Backport-to: 21.0 + +Multiple ``Backport-to:`` lines are allowed. + +The last option is deprecated and mostly here for historical reasons +dating back to when patch submision was done via emails: using a ``Cc:`` +tag. Support for this tag will be removed at some point. +Here are some examples of such a note:: Cc: mesa-stable Cc: 20.0