Mesa (main): bin/gen_release_notes: Fix commits with multiple Closes:

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 4 23:04:52 UTC 2021


Module: Mesa
Branch: main
Commit: da00a11bf28f9b9898efa1e6184fa27ea8277a94
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=da00a11bf28f9b9898efa1e6184fa27ea8277a94

Author: Dylan Baker <dylan.c.baker at intel.com>
Date:   Wed Aug  4 11:37:12 2021 -0700

bin/gen_release_notes: Fix commits with multiple Closes:

Currently we'd only handle the last one, not all of them. Which is
clearely not correct.

Reviewed-by: Eric Engestrom <eric at engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12201>

---

 bin/gen_release_notes.py      | 16 +++++++---------
 bin/gen_release_notes_test.py | 33 ++++++++++++++++++++++++++++++++-
 2 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/bin/gen_release_notes.py b/bin/gen_release_notes.py
index bfc65ca92b7..9b14c908bb5 100755
--- a/bin/gen_release_notes.py
+++ b/bin/gen_release_notes.py
@@ -195,15 +195,13 @@ async def parse_issues(commits: str) -> typing.List[str]:
         for line in reversed(out):
             if line.startswith('Closes:'):
                 bug = line.lstrip('Closes:').strip()
-                break
-        else:
-            raise Exception('No closes found?')
-            
-        if bug.startswith('https://gitlab.freedesktop.org/mesa/mesa'):
-            # This means we have a bug in the form "Closes: https://..."
-            issues.append(os.path.basename(urllib.parse.urlparse(bug).path))
-        elif bug.startswith('#'):
-            issues.append(bug.lstrip('#'))
+                if bug.startswith('https://gitlab.freedesktop.org/mesa/mesa'):
+                    # This means we have a bug in the form "Closes: https://..."
+                    issues.append(os.path.basename(urllib.parse.urlparse(bug).path))
+                elif ',' in bug:
+                    issues.extend([b.strip().lstrip('#') for b in bug.split(',')])
+                elif bug.startswith('#'):
+                    issues.append(bug.lstrip('#'))
 
     return issues
 
diff --git a/bin/gen_release_notes_test.py b/bin/gen_release_notes_test.py
index 194fbc745ac..114b99469fe 100644
--- a/bin/gen_release_notes_test.py
+++ b/bin/gen_release_notes_test.py
@@ -117,6 +117,37 @@ async def test_gather_commits():
             ''',
             [],
         ),
+
+        # Test  multiple issues on one line
+        (
+            '''\
+            Fix many bugs
+
+            Closes: #1, #2
+            ''',
+            ['1', '2'],
+        ),
+
+        # Test multiple closes
+        (
+            '''\
+            Fix many bugs
+
+            Closes: #1
+            Closes: #2
+            ''',
+            ['1', '2'],
+        ),
+        (
+            '''\
+            With long form
+
+            Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3456
+            Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3457
+            Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3458
+            ''',
+            ['3456', '3457', '3458'],
+        ),
     ])
 async def test_parse_issues(content: str, bugs: typing.List[str]) -> None:
     mock_com = mock.AsyncMock(return_value=(textwrap.dedent(content).encode(), ''))
@@ -127,4 +158,4 @@ async def test_parse_issues(content: str, bugs: typing.List[str]) -> None:
     with mock.patch('bin.gen_release_notes.asyncio.create_subprocess_exec', mock_exec), \
             mock.patch('bin.gen_release_notes.gather_commits', mock.AsyncMock(return_value='sha\n')):
         ids = await parse_issues('1234 not used')
-        assert ids == bugs
+        assert set(ids) == set(bugs)



More information about the mesa-commit mailing list