Revert "Revert "Add support for customizable changelog formats""

This reverts commit 7147e4a050.
This commit is contained in:
Devan Goodwin 2012-02-01 14:36:47 -04:00
parent 7147e4a050
commit 7b14e00568
3 changed files with 29 additions and 12 deletions

View file

@ -710,7 +710,7 @@ class InitModule(BaseCliModule):
out_f.write( out_f.write(
"default_tagger = %s\n" % 'tito.tagger.VersionTagger') "default_tagger = %s\n" % 'tito.tagger.VersionTagger')
out_f.write("changelog_do_not_remove_cherrypick = 0\n") 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() out_f.close()
print(" - wrote %s" % GLOBAL_BUILD_PROPS_FILENAME) print(" - wrote %s" % GLOBAL_BUILD_PROPS_FILENAME)

View file

@ -146,25 +146,35 @@ class VersionTagger(object):
line = m.group(1) line = m.group(1)
return line 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 If you have set changelog_format in [globalconfig], it will return
string '(%ae)' 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 = '' result = ''
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") if (self.config.has_option("globalconfig", "changelog_with_email")
and self.config.get("globalconfig", "changelog_with_email")) or \ and self.config.get("globalconfig", "changelog_with_email")) or \
not self.config.has_option("globalconfig", "changelog_with_email"): not self.config.has_option("globalconfig", "changelog_with_email"):
result = ' (%ae)' with_email = ' (%ae)'
result = "%%s%s" % with_email
return result return result
def _generate_default_changelog(self, last_tag): def _generate_default_changelog(self, last_tag):
""" """
Run git-log and will generate changelog, which still can be edited by user Run git-log and will generate changelog, which still can be edited by user
in _make_changelog. in _make_changelog.
""" """
patch_command = "git log --pretty='format:%%s%s'" \ patch_command = "git log --pretty='format:%s'" \
" --relative %s..%s -- %s" % (self._changelog_email(), last_tag, "HEAD", ".") " --relative %s..%s -- %s" % (self._changelog_format(), last_tag, "HEAD", ".")
output = run_command(patch_command) output = run_command(patch_command)
result = [] result = []
for line in output.split('\n'): for line in output.split('\n'):

View file

@ -52,9 +52,16 @@ This option is used in project specific tito.props only, and allows that project
tagger:: 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. 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:: changelog_with_email::
If set to 0, then entries in changelog (subject of commits) are not followed by If set to 0, then entries in changelog (subject of commits) are not
email of commiter. Default is 1. 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:: changelog_do_not_remove_cherrypick::
If set to 0, it will not remove from cherry picked commits the part "(cherry If set to 0, it will not remove from cherry picked commits the part "(cherry