From 63abc26b0fc7750f97ce4cf8d01116edf6b1c180 Mon Sep 17 00:00:00 2001 From: John Eckersberg Date: Tue, 31 Jan 2012 16:14:59 -0500 Subject: [PATCH] Add support for customizable changelog formats This adds a new option, changelog_format, which allows specifying the full format of generated changelog entries. This also deprecates use of changelog_with_email, since it is a subset of a fully-customizable changelog format. --- src/tito/cli.py | 2 +- src/tito/tagger.py | 28 +++++++++++++++++++--------- tito.props.5.asciidoc | 11 +++++++++-- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/tito/cli.py b/src/tito/cli.py index d1b1eef..25d24ae 100644 --- a/src/tito/cli.py +++ b/src/tito/cli.py @@ -710,7 +710,7 @@ class InitModule(BaseCliModule): out_f.write( "default_tagger = %s\n" % 'tito.tagger.VersionTagger') out_f.write("changelog_do_not_remove_cherrypick = 0\n") - out_f.write("changelog_with_email = 1\n") + out_f.write("changelog_format = %s %(ae)\n") out_f.close() print(" - wrote %s" % GLOBAL_BUILD_PROPS_FILENAME) diff --git a/src/tito/tagger.py b/src/tito/tagger.py index 5f5de25..cc5b432 100644 --- a/src/tito/tagger.py +++ b/src/tito/tagger.py @@ -146,25 +146,35 @@ class VersionTagger(object): line = m.group(1) return line - def _changelog_email(self): + + def _changelog_format(self): """ - if you have set changelog_with_email in [globalconfig] set to 1, it will return - string '(%ae)' + If you have set changelog_format in [globalconfig], it will return + that string. Otherwise, return one of two defaults: + + - '%s (%ae)', if changelog_with_email is unset or evaluates to True + - '%s', if changelog_with_email is set and evaluates to False """ result = '' - if (self.config.has_option("globalconfig", "changelog_with_email") - and self.config.get("globalconfig", "changelog_with_email")) or \ - not self.config.has_option("globalconfig", "changelog_with_email"): - result = ' (%ae)' + if self.config.has_option("globalconfig", "changelog_format"): + result = self.config.get("globalconfig", "changelog_format") + else: + with_email = '' + if (self.config.has_option("globalconfig", "changelog_with_email") + and self.config.get("globalconfig", "changelog_with_email")) or \ + not self.config.has_option("globalconfig", "changelog_with_email"): + with_email = ' (%ae)' + result = "%%s%s" % with_email return result + def _generate_default_changelog(self, last_tag): """ Run git-log and will generate changelog, which still can be edited by user in _make_changelog. """ - patch_command = "git log --pretty='format:%%s%s'" \ - " --relative %s..%s -- %s" % (self._changelog_email(), last_tag, "HEAD", ".") + patch_command = "git log --pretty='format:%s'" \ + " --relative %s..%s -- %s" % (self._changelog_format(), last_tag, "HEAD", ".") output = run_command(patch_command) result = [] for line in output.split('\n'): diff --git a/tito.props.5.asciidoc b/tito.props.5.asciidoc index 2d5153a..cd2ac71 100644 --- a/tito.props.5.asciidoc +++ b/tito.props.5.asciidoc @@ -52,9 +52,16 @@ This option is used in project specific tito.props only, and allows that project tagger:: This option is used in project specific tito.props only, and allows that project to override the default_tagger defined in rel-eng/tito.props. +changelog_format:: +This option is used to control the formatting of entries when +generating changelog entries. The default value is "%s (%ae)". See +PRETTY FORMATS in git-log(1) for more information. + changelog_with_email:: -If set to 0, then entries in changelog (subject of commits) are not followed by -email of commiter. Default is 1. +If set to 0, then entries in changelog (subject of commits) are not +followed by email of commiter. Default is 1. This option is +deprecated and provided for backwards-compatibility only. New +configurations should consider changelog_format instead. changelog_do_not_remove_cherrypick:: If set to 0, it will not remove from cherry picked commits the part "(cherry