]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Allow gitchangelog to include commit sha
authorNicki Křížek <nicki@isc.org>
Mon, 22 Jul 2024 12:28:28 +0000 (14:28 +0200)
committerNicki Křížek <nicki@isc.org>
Wed, 24 Jul 2024 15:43:10 +0000 (17:43 +0200)
Add an option which can be used to put short commit sha at the end of
each commit subject line in the generated changelog.

contrib/gitchangelog/gitchangelog.py

index 84380bab759e405f177732c552e0d20036e2f0ec..cc347bccd0a953c76882cb8f9c3989909af9e75f 100755 (executable)
@@ -1503,12 +1503,15 @@ def rest_py(data, opts={}):
                 s += "\n" + rest_title(section_label, "~")
 
             for commit in section["commits"]:
-                s += render_commit(commit)
+                s += render_commit(commit, opts)
         return s
 
     def render_commit(commit, opts=opts):
         subject = commit["subject"]
 
+        if opts["include_commit_sha"]:
+            subject += " ``%s``" % commit["commit"].sha1_short
+
         entry = indent("\n".join(textwrap.wrap(subject)), first="- ").strip() + "\n"
 
         if commit["body"]:
@@ -1821,6 +1824,7 @@ def versions_data_iter(
 def changelog(
     output_engine=rest_py,
     unreleased_version_label="unreleased",
+    include_commit_sha=False,
     warn=warn,  ## Mostly used for test
     **kwargs
 ):
@@ -1835,6 +1839,7 @@ def changelog(
     ``versions_data_iter(..)``.
 
     :param unreleased_version_label: version label for untagged commits
+    :param include_commit_sha: whether message should contain commit sha
     :param output_engine: callable to render the changelog data
     :param warn: callable to output warnings, mocked by tests
 
@@ -1844,6 +1849,7 @@ def changelog(
 
     opts = {
         "unreleased_version_label": unreleased_version_label,
+        "include_commit_sha": include_commit_sha,
     }
 
     ## Setting main container of changelog elements
@@ -2205,6 +2211,7 @@ def main():
             ignore_regexps=config["ignore_regexps"],
             section_regexps=config["section_regexps"],
             unreleased_version_label=config["unreleased_version_label"],
+            include_commit_sha=config["include_commit_sha"],
             tag_filter_regexp=config["tag_filter_regexp"],
             output_engine=config.get("output_engine", rest_py),
             include_merge=config.get("include_merge", True),