From: Nicki Křížek Date: Mon, 22 Jul 2024 12:28:28 +0000 (+0200) Subject: Allow gitchangelog to include commit sha X-Git-Tag: alessio/regression/026024a6ae~30^2~8 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=c2b23fa2de0b574104884dc677fe996bb245f8fe;p=thirdparty%2Fbind9.git Allow gitchangelog to include commit sha Add an option which can be used to put short commit sha at the end of each commit subject line in the generated changelog. --- diff --git a/contrib/gitchangelog/gitchangelog.py b/contrib/gitchangelog/gitchangelog.py index 84380bab759..cc347bccd0a 100755 --- a/contrib/gitchangelog/gitchangelog.py +++ b/contrib/gitchangelog/gitchangelog.py @@ -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),