mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-24 04:32:46 +00:00
Partial fix for broken tag suffixes.
Suffix now appears at end of tag as before.
This commit is contained in:
parent
18babd175f
commit
ca86a74fa5
2 changed files with 27 additions and 13 deletions
|
@ -236,6 +236,7 @@ class VersionTagger(ConfigObject):
|
||||||
found_changelog = True
|
found_changelog = True
|
||||||
|
|
||||||
old_version = get_latest_tagged_version(self.project_name)
|
old_version = get_latest_tagged_version(self.project_name)
|
||||||
|
debug("Got old_version: %s" % old_version)
|
||||||
|
|
||||||
fd, name = tempfile.mkstemp()
|
fd, name = tempfile.mkstemp()
|
||||||
write(fd, "# Create your changelog entry below:\n")
|
write(fd, "# Create your changelog entry below:\n")
|
||||||
|
@ -258,6 +259,7 @@ class VersionTagger(ConfigObject):
|
||||||
else:
|
else:
|
||||||
if old_version is not None:
|
if old_version is not None:
|
||||||
last_tag = self._get_new_tag(old_version)
|
last_tag = self._get_new_tag(old_version)
|
||||||
|
debug("last_tag = %s" % last_tag)
|
||||||
output = self._generate_default_changelog(last_tag)
|
output = self._generate_default_changelog(last_tag)
|
||||||
else:
|
else:
|
||||||
output = self._new_changelog_msg
|
output = self._new_changelog_msg
|
||||||
|
@ -448,10 +450,13 @@ class VersionTagger(ConfigObject):
|
||||||
file here stores the latest package version (for the git branch you
|
file here stores the latest package version (for the git branch you
|
||||||
are on) as well as the relative path to the project's code. (from the
|
are on) as well as the relative path to the project's code. (from the
|
||||||
git root)
|
git root)
|
||||||
|
|
||||||
|
Release, and tag suffix, are included here, but package name is not.
|
||||||
"""
|
"""
|
||||||
self._clear_package_metadata()
|
self._clear_package_metadata()
|
||||||
|
|
||||||
new_version_w_suffix = self._get_suffixed_version(new_version)
|
# NOTE: This is actually version-release-suffix
|
||||||
|
new_version_w_suffix = '%s%s' % (new_version, self._get_suffix())
|
||||||
# Write out our package metadata:
|
# Write out our package metadata:
|
||||||
metadata_file = os.path.join(self.rel_eng_dir, "packages",
|
metadata_file = os.path.join(self.rel_eng_dir, "packages",
|
||||||
self.project_name)
|
self.project_name)
|
||||||
|
@ -468,7 +473,6 @@ class VersionTagger(ConfigObject):
|
||||||
'[%(name)s] %(release_type)s [%(version)s].')
|
'[%(name)s] %(release_type)s [%(version)s].')
|
||||||
if self.config.has_option(BUILDCONFIG_SECTION, "tag_commit_message_format"):
|
if self.config.has_option(BUILDCONFIG_SECTION, "tag_commit_message_format"):
|
||||||
fmt = self.config.get(BUILDCONFIG_SECTION, "tag_commit_message_format")
|
fmt = self.config.get(BUILDCONFIG_SECTION, "tag_commit_message_format")
|
||||||
new_version_w_suffix = self._get_suffixed_version(new_version)
|
|
||||||
try:
|
try:
|
||||||
msg = fmt % {
|
msg = fmt % {
|
||||||
'name': self.project_name,
|
'name': self.project_name,
|
||||||
|
@ -550,9 +554,10 @@ class VersionTagger(ConfigObject):
|
||||||
|
|
||||||
def _get_new_tag(self, version_and_release):
|
def _get_new_tag(self, version_and_release):
|
||||||
""" Returns the actual tag we'll be creating. """
|
""" Returns the actual tag we'll be creating. """
|
||||||
suffixed_version = self._get_suffixed_version(self._get_version(version_and_release))
|
version = self._get_version(version_and_release)
|
||||||
|
suffix = self._get_suffix()
|
||||||
release = self._get_release(version_and_release)
|
release = self._get_release(version_and_release)
|
||||||
return self._get_tag_for_version(suffixed_version, release)
|
return self._get_tag_for_version(version, release, suffix=suffix)
|
||||||
|
|
||||||
def _get_release(self, version_and_release):
|
def _get_release(self, version_and_release):
|
||||||
return version_and_release.split('-')[-1]
|
return version_and_release.split('-')[-1]
|
||||||
|
@ -560,14 +565,14 @@ class VersionTagger(ConfigObject):
|
||||||
def _get_version(self, version_and_release):
|
def _get_version(self, version_and_release):
|
||||||
return version_and_release.split('-')[-2]
|
return version_and_release.split('-')[-2]
|
||||||
|
|
||||||
def _get_suffixed_version(self, version):
|
def _get_suffix(self):
|
||||||
""" If global config specifies a tag suffix, use it """
|
""" If global config specifies a tag suffix, use it """
|
||||||
suffix = ""
|
suffix = ""
|
||||||
if self.config.has_option(BUILDCONFIG_SECTION, "tag_suffix"):
|
if self.config.has_option(BUILDCONFIG_SECTION, "tag_suffix"):
|
||||||
suffix = self.config.get(BUILDCONFIG_SECTION, "tag_suffix")
|
suffix = self.config.get(BUILDCONFIG_SECTION, "tag_suffix")
|
||||||
return "{0}{1}".format(version, suffix)
|
return suffix
|
||||||
|
|
||||||
def _get_tag_for_version(self, version, release=''):
|
def _get_tag_for_version(self, version, release='', suffix=''):
|
||||||
"""
|
"""
|
||||||
Determine what the tag will look like for a given version.
|
Determine what the tag will look like for a given version.
|
||||||
Can be overridden when custom taggers override counterpart,
|
Can be overridden when custom taggers override counterpart,
|
||||||
|
@ -576,11 +581,12 @@ class VersionTagger(ConfigObject):
|
||||||
if self.config.has_option(BUILDCONFIG_SECTION, "tag_format"):
|
if self.config.has_option(BUILDCONFIG_SECTION, "tag_format"):
|
||||||
tag_format = self.config.get(BUILDCONFIG_SECTION, "tag_format")
|
tag_format = self.config.get(BUILDCONFIG_SECTION, "tag_format")
|
||||||
else:
|
else:
|
||||||
tag_format = "{component}-{version}-{release}"
|
tag_format = "{component}-{version}-{release}{suffix}"
|
||||||
kwargs = {
|
kwargs = {
|
||||||
'component': self.project_name,
|
'component': self.project_name,
|
||||||
'version': version,
|
'version': version,
|
||||||
'release': release
|
'release': release,
|
||||||
|
'suffix': suffix
|
||||||
}
|
}
|
||||||
# Strip extra dashes if one of the params is empty
|
# Strip extra dashes if one of the params is empty
|
||||||
return tag_format.format(**kwargs).strip('-')
|
return tag_format.format(**kwargs).strip('-')
|
||||||
|
|
|
@ -58,15 +58,12 @@ class VersionTaggerTest(unittest.TestCase):
|
||||||
tito("init")
|
tito("init")
|
||||||
run_command('sed -i "s;tagger.*;tagger = tito.tagger.VersionTagger;g" .tito/tito.props')
|
run_command('sed -i "s;tagger.*;tagger = tito.tagger.VersionTagger;g" .tito/tito.props')
|
||||||
run_command('echo "offline = true" >> .tito/tito.props')
|
run_command('echo "offline = true" >> .tito/tito.props')
|
||||||
run_command('echo "tag_format = {component}-v{version}" >> .tito/tito.props')
|
|
||||||
run_command('git add .tito/tito.props')
|
run_command('git add .tito/tito.props')
|
||||||
run_command("git commit -m 'set offline in tito.props'")
|
run_command("git commit -m 'set offline in tito.props'")
|
||||||
|
|
||||||
# Init RPM package
|
# Init RPM package
|
||||||
self.create_rpm_package()
|
self.create_rpm_package()
|
||||||
|
|
||||||
# Run tito release
|
|
||||||
tito("tag release --accept-auto-changelog")
|
|
||||||
|
|
||||||
def write_file(self, path, contents):
|
def write_file(self, path, contents):
|
||||||
out_f = open(path, 'w')
|
out_f = open(path, 'w')
|
||||||
|
@ -83,5 +80,16 @@ class VersionTaggerTest(unittest.TestCase):
|
||||||
"""
|
"""
|
||||||
Check that the tag is correct
|
Check that the tag is correct
|
||||||
"""
|
"""
|
||||||
|
# Run tito tag
|
||||||
|
run_command('echo "tag_format = {component}-v{version}" >> .tito/tito.props')
|
||||||
|
tito("tag --accept-auto-changelog")
|
||||||
latest_tag = getoutput("git describe --abbrev=0 --tags")
|
latest_tag = getoutput("git describe --abbrev=0 --tags")
|
||||||
assert latest_tag == 'hello_tito-v0.1.8'
|
self.assertEqual('hello_tito-v0.1.8', latest_tag)
|
||||||
|
# TODO: test package metadata looks correct
|
||||||
|
|
||||||
|
def test_tag_with_suffix(self):
|
||||||
|
run_command('echo "tag_suffix = .fc1_17" >> .tito/tito.props')
|
||||||
|
tito("tag --accept-auto-changelog")
|
||||||
|
latest_tag = getoutput("git describe --abbrev=0 --tags")
|
||||||
|
self.assertEqual('hello_tito-0.1.8-1.fc1_17', latest_tag)
|
||||||
|
# TODO: test package metadata looks correct
|
||||||
|
|
Loading…
Add table
Reference in a new issue