Fix changelog generation when introducing tag suffixes.

This commit is contained in:
Devan Goodwin 2018-01-02 15:22:53 -04:00
parent ca86a74fa5
commit 46d09a1239
3 changed files with 12 additions and 3 deletions

View file

@ -235,6 +235,9 @@ class VersionTagger(ConfigObject):
if not found_changelog and line.startswith("%changelog"):
found_changelog = True
# WARNING: This is the last tag, minus the assumed "PKGNAME-" prefix. This complicates
# the appearance that we can control the package name in the tag with a custom tag_format,
# at present we cannot. (as it would break old/existing package metadata files)
old_version = get_latest_tagged_version(self.project_name)
debug("Got old_version: %s" % old_version)
@ -258,7 +261,7 @@ class VersionTagger(ConfigObject):
write(fd, "\n")
else:
if old_version is not None:
last_tag = self._get_new_tag(old_version)
last_tag = "%s-%s" % (self.project_name, old_version)
debug("last_tag = %s" % last_tag)
output = self._generate_default_changelog(last_tag)
else:

View file

@ -64,7 +64,6 @@ class VersionTaggerTest(unittest.TestCase):
# Init RPM package
self.create_rpm_package()
def write_file(self, path, contents):
out_f = open(path, 'w')
out_f.write(contents)

View file

@ -14,7 +14,7 @@
import os
from tito.builder import Builder, UpstreamBuilder
from tito.common import tag_exists_locally, check_tag_exists
from tito.common import tag_exists_locally, check_tag_exists, run_command
from tito.release import Releaser
from tito.compat import getoutput
from functional.fixture import TitoGitTestFixture, tito
@ -58,6 +58,13 @@ class SingleProjectTests(TitoGitTestFixture):
tito("tag --accept-auto-changelog --debug")
check_tag_exists("%s-0.0.2-1" % PKG_NAME, offline=True)
def test_tag_with_suffix(self):
# Append a tag suffix to our global tito.props:
run_command('echo "tag_suffix = .fc1_17" >> .tito/tito.props')
# Create a 0.0.2 now with the addition of a tag suffix:
tito("tag --accept-auto-changelog --debug")
check_tag_exists("%s-0.0.2-1.fc1_17" % PKG_NAME, offline=True)
def test_tag_with_version(self):
tito("tag --accept-auto-changelog --debug --use-version 9.0.0")
check_tag_exists("%s-9.0.0-1" % PKG_NAME, offline=True)