mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-24 04:32:46 +00:00
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.
This commit is contained in:
parent
1c500dbefc
commit
63abc26b0f
3 changed files with 29 additions and 12 deletions
|
@ -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)
|
||||||
|
|
||||||
|
|
|
@ -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_with_email")
|
if self.config.has_option("globalconfig", "changelog_format"):
|
||||||
and self.config.get("globalconfig", "changelog_with_email")) or \
|
result = self.config.get("globalconfig", "changelog_format")
|
||||||
not self.config.has_option("globalconfig", "changelog_with_email"):
|
else:
|
||||||
result = ' (%ae)'
|
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
|
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'):
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Add table
Reference in a new issue