Added --use-release flag for tito tag

When multiple tags exist for one version of a project, or when a version
is passed to `tito tag --use-version` that does not exactly correspond
with a tag in the repository's git history, the auto-generated release
is not guaranteed to monotonically increase. In order for users to
overcome this issue without building complicated logic into `tito`, it
is simpler to allow users to provide a literal release string to use.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
This commit is contained in:
Steve Kuznetsov 2016-11-29 15:46:52 -05:00
parent bb7881dfc6
commit a19a366213
No known key found for this signature in database
GPG key ID: 366E054B30FC03A2
3 changed files with 27 additions and 13 deletions

View file

@ -620,6 +620,8 @@ class TagModule(BaseCliModule):
"specified in spec file to tag package."))
self.parser.add_option("--use-version", dest="use_version",
help=("Update the spec file with the specified version."))
self.parser.add_option("--use-release", dest="use_release",
help=("Update the spec file with the specified release."))
self.parser.add_option("--no-auto-changelog", action="store_true",
default=False,

View file

@ -100,6 +100,8 @@ class VersionTagger(ConfigObject):
self._new_changelog_msg = options.auto_changelog_msg
if options.use_version:
self._use_version = options.use_version
if options.use_release:
self._use_release = options.use_release
if options.changelog:
self._changelog = options.changelog
@ -414,13 +416,6 @@ class VersionTagger(ConfigObject):
self._use_version,
"\n"
))
match = re.match(release_regex, line)
if match:
line = "".join((match.group(1),
reset_release(match.group(2)),
"\n"
))
else:
match = re.match(version_regex, line)
if match:
@ -429,12 +424,21 @@ class VersionTagger(ConfigObject):
"\n"
))
match = re.match(release_regex, line)
if match:
line = "".join((match.group(1),
reset_release(match.group(2)),
"\n"
))
if not release and not zstream:
if hasattr(self, '_use_release'):
match = re.match(release_regex, line)
if match:
line = "".join((match.group(1),
self._use_release,
"\n"
))
else:
match = re.match(release_regex, line)
if match:
line = "".join((match.group(1),
reset_release(match.group(2)),
"\n"
))
out_f.write(line)

View file

@ -62,6 +62,14 @@ 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_release(self):
tito("tag --accept-auto-changelog --debug --use-release dummyvalue")
check_tag_exists("%s-0.0.2-dummyvalue" % PKG_NAME, offline=True)
def test_tag_with_version_and_release(self):
tito("tag --accept-auto-changelog --debug --use-version 9.0.0 --use-release dummyvalue")
check_tag_exists("%s-9.0.0-dummyvalue" % 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)