]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Sort changelog & relnotes entries by issue number
authorNicki Křížek <nicki@isc.org>
Tue, 13 Aug 2024 15:20:54 +0000 (17:20 +0200)
committerNicki Křížek <nicki@isc.org>
Tue, 20 Aug 2024 11:51:47 +0000 (11:51 +0000)
To reduce the friction when handling the release notes, it is preferable
to have the sections sorted by issue number, rather than merge order.
Fallback to commit subject line if unavailable (e.g. for changelog
entries).

(cherry picked from commit 759948fffefb15b2119bd6e68a529f9daa7e41f4)

contrib/gitchangelog/gitchangelog.py

index c0d444baf14fbe9a4d07b73b5cbbe9a4530a24ce..b466c38c709418f6af3fa8e31934f08c89cd4a10 100755 (executable)
@@ -1802,6 +1802,13 @@ def versions_data_iter(
             ):
                 continue
 
+            body = body_process(commit.body)
+
+            ## Extract gitlab issue number
+            issue = None
+            if match := re.search(r".*:gl:`#([0-9]+)`", body):
+                issue = int(match.group(1))
+
             matched_section = first_matching(section_regexps, commit.subject)
 
             ## Finally storing the commit in the matching section
@@ -1811,11 +1818,21 @@ def versions_data_iter(
                     "author": commit.author_name,
                     "authors": commit.author_names,
                     "subject": subject_process(commit.subject),
-                    "body": body_process(commit.body),
+                    "body": body,
                     "commit": commit,
+                    "issue": issue,
                 }
             )
 
+        ## Sort sections by issue number or title
+        for section_key in sections.keys():
+            sections[section_key].sort(
+                key=lambda c: (
+                    c["issue"] if c["issue"] is not None else sys.maxsize,
+                    c["subject"],
+                )
+            )
+
         ## Flush current version
         current_version["sections"] = [
             {"label": k, "commits": sections[k]} for k in section_order if k in sections
@@ -1830,7 +1847,7 @@ def changelog(
     unreleased_version_label="unreleased",
     include_commit_sha=False,
     warn=warn,  ## Mostly used for test
-    **kwargs
+    **kwargs,
 ):
     """Returns a string containing the changelog of given repository