mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 12:12:47 +00:00
Add ability to specify a custom changelog during tag
This commit is contained in:
parent
80ce4c7e2b
commit
092dc1e6c5
5 changed files with 53 additions and 11 deletions
|
@ -61,6 +61,7 @@ __tito_report_opts='
|
|||
__tito_tag_opts='
|
||||
--accept-auto-changelog
|
||||
--auto-changelog-message=
|
||||
--changelog
|
||||
--debug
|
||||
--help
|
||||
--keep-version
|
||||
|
|
|
@ -634,6 +634,10 @@ class TagModule(BaseCliModule):
|
|||
help=("Use MESSAGE as the default changelog message for "
|
||||
"new packages"))
|
||||
|
||||
self.parser.add_option("--changelog",
|
||||
dest="changelog", action="append",
|
||||
help=("Supply a custom changelog message to be used for this tag"))
|
||||
|
||||
self.parser.add_option("--undo", "-u", dest="undo", action="store_true",
|
||||
help="Undo the most recent (un-pushed) tag.")
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ class VersionTagger(ConfigObject):
|
|||
self._no_auto_changelog = False
|
||||
self._accept_auto_changelog = False
|
||||
self._new_changelog_msg = "new package built with tito"
|
||||
self._changelog = None
|
||||
self.offline = offline
|
||||
|
||||
def run(self, options):
|
||||
|
@ -92,6 +93,8 @@ class VersionTagger(ConfigObject):
|
|||
self._new_changelog_msg = options.auto_changelog_msg
|
||||
if options.use_version:
|
||||
self._use_version = options.use_version
|
||||
if options.changelog:
|
||||
self._changelog = options.changelog
|
||||
|
||||
self.check_tag_precondition()
|
||||
|
||||
|
@ -225,13 +228,6 @@ class VersionTagger(ConfigObject):
|
|||
|
||||
old_version = get_latest_tagged_version(self.project_name)
|
||||
|
||||
# don't die if this is a new package with no history
|
||||
if old_version is not None:
|
||||
last_tag = "%s-%s" % (self.project_name, old_version)
|
||||
output = self._generate_default_changelog(last_tag)
|
||||
else:
|
||||
output = self._new_changelog_msg
|
||||
|
||||
fd, name = tempfile.mkstemp()
|
||||
write(fd, "# Create your changelog entry below:\n")
|
||||
if self.git_email is None or (('HIDE_EMAIL' in self.user_config) and
|
||||
|
@ -243,10 +239,24 @@ class VersionTagger(ConfigObject):
|
|||
|
||||
write(fd, header)
|
||||
|
||||
for cmd_out in output.split("\n"):
|
||||
write(fd, "- ")
|
||||
write(fd, "\n ".join(textwrap.wrap(cmd_out, 77)))
|
||||
write(fd, "\n")
|
||||
# don't die if this is a new package with no history
|
||||
if self._changelog is not None:
|
||||
for entry in self._changelog:
|
||||
if not entry.startswith('-'):
|
||||
entry = '- ' + entry
|
||||
write(fd, entry)
|
||||
write(fd, "\n")
|
||||
else:
|
||||
if old_version is not None:
|
||||
last_tag = "%s-%s" % (self.project_name, old_version)
|
||||
output = self._generate_default_changelog(last_tag)
|
||||
else:
|
||||
output = self._new_changelog_msg
|
||||
|
||||
for cmd_out in output.split("\n"):
|
||||
write(fd, "- ")
|
||||
write(fd, "\n ".join(textwrap.wrap(cmd_out, 77)))
|
||||
write(fd, "\n")
|
||||
|
||||
write(fd, "\n")
|
||||
|
||||
|
|
|
@ -61,6 +61,28 @@ class SingleProjectTests(TitoGitTestFixture):
|
|||
tito("tag --accept-auto-changelog --debug --use-version 9.0.0")
|
||||
check_tag_exists("%s-9.0.0-1" % PKG_NAME, offline=True)
|
||||
|
||||
def test_tag_with_changelog(self):
|
||||
tito("tag --accept-auto-changelog --use-version 9.0.0 --changelog='-Test'")
|
||||
check_tag_exists("%s-9.0.0-1" % PKG_NAME, offline=True)
|
||||
|
||||
changelog = getoutput("cat *.spec")
|
||||
self.assertTrue('-Test' in changelog)
|
||||
|
||||
def test_tag_with_changelog_format(self):
|
||||
tito("tag --accept-auto-changelog --use-version 9.0.0 --changelog=Test")
|
||||
check_tag_exists("%s-9.0.0-1" % PKG_NAME, offline=True)
|
||||
|
||||
changelog = getoutput("cat *.spec")
|
||||
self.assertTrue('- Test' in changelog)
|
||||
|
||||
def test_tag_with_changelog_multiple(self):
|
||||
tito("tag --accept-auto-changelog --use-version 9.0.0 --changelog=Test --changelog=Fake")
|
||||
check_tag_exists("%s-9.0.0-1" % PKG_NAME, offline=True)
|
||||
|
||||
changelog = getoutput("cat *.spec")
|
||||
self.assertTrue('- Test' in changelog)
|
||||
self.assertTrue('- Fake' in changelog)
|
||||
|
||||
def test_undo_tag(self):
|
||||
os.chdir(self.repo_dir)
|
||||
original_head = getoutput('git show-ref -s refs/heads/master')
|
||||
|
|
|
@ -101,6 +101,11 @@ Automatically accept the generated changelog.
|
|||
Use 'MESSAGE' as the default changelog message for new
|
||||
packages
|
||||
|
||||
--changelog='MESSAGE'::
|
||||
Use 'MESSAGE' as the changelog when tagging, this can be specified
|
||||
everytime a package is tagged. Useful when needing to generate
|
||||
custom changelogs. This will override the auto generated changelog.
|
||||
|
||||
-u, --undo::
|
||||
Undo the most recent (un-pushed) tag.
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue