pick-ui: add `Backport-to: XX.Y` nomination
authorEric Engestrom <eric@engestrom.ch>
Mon, 18 Oct 2021 22:02:52 +0000 (23:02 +0100)
committerMarge Bot <emma+marge@anholt.net>
Sat, 7 Oct 2023 19:00:17 +0000 (19:00 +0000)
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13664>

bin/pick/core.py
bin/pick/core_test.py
docs/submittingpatches.rst

index d7dfb12..cde0586 100644 (file)
@@ -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*\<?mesa-stable',
                    flags=re.MULTILINE | re.IGNORECASE)
 IS_REVERT = re.compile(r'This reverts commit ([0-9a-f]{40})')
+IS_BACKPORT = re.compile(r'^\s*backport-to:\s*(\d{2}\.\d),?\s*(\d{2}\.\d)?',
+                         flags=re.MULTILINE | re.IGNORECASE)
 
 # XXX: hack
 SEM = asyncio.Semaphore(50)
@@ -73,6 +75,7 @@ class NominationType(enum.Enum):
     FIXES = 1
     REVERT = 2
     NONE = 3
+    BACKPORT = 4
 
 
 @enum.unique
@@ -289,6 +292,12 @@ async def resolve_nomination(commit: 'Commit', version: str) -> '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
index f2ac6ed..d7579be 100644 (file)
@@ -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 <samuel.pitoiset@gmail.com>
+                Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
+            """)
+
+            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 <pierre-eric.pelloux-prayer@amd.com>
+            """)
+
+            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 <pierre-eric.pelloux-prayer@amd.com>
+            """)
+
+            backport_to = core.IS_BACKPORT.search(message)
+            assert backport_to is not None
+            assert backport_to.groups() == ('19.1', '19.2')
+
 
 class TestResolveNomination:
 
@@ -324,6 +376,28 @@ class TestResolveNomination:
         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.')
         c = core.Commit('abcdef1234567890', 'a commit')
@@ -348,6 +422,21 @@ class TestResolveNomination:
         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(
             b'Fixes: 3d09bb390a39 (etnaviv: GC7000: State changes for HALTI3..5)\n'
index 31f267a..dfed1fa 100644 (file)
@@ -100,7 +100,7 @@ Patch formatting
       Acked-by: Joe Hacker <jhacker@foo.com>
 
 -  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 <mesa-stable>