From 46d09a12392cadab1dbee120436ed6b911b470b9 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 2 Jan 2018 15:22:53 -0400 Subject: [PATCH] Fix changelog generation when introducing tag suffixes. --- src/tito/tagger/main.py | 5 ++++- test/functional/custom_tag_tests.py | 1 - test/functional/singleproject_tests.py | 9 ++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/tito/tagger/main.py b/src/tito/tagger/main.py index d732a25..1ba4fae 100644 --- a/src/tito/tagger/main.py +++ b/src/tito/tagger/main.py @@ -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: diff --git a/test/functional/custom_tag_tests.py b/test/functional/custom_tag_tests.py index d3aa8d8..4b21410 100644 --- a/test/functional/custom_tag_tests.py +++ b/test/functional/custom_tag_tests.py @@ -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) diff --git a/test/functional/singleproject_tests.py b/test/functional/singleproject_tests.py index 8354fd0..341f611 100644 --- a/test/functional/singleproject_tests.py +++ b/test/functional/singleproject_tests.py @@ -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)