Conflicts:
	src/tito/cli.py
This commit is contained in:
Devan Goodwin 2011-10-24 12:26:31 -03:00
commit 60ce1c79e9
3 changed files with 47 additions and 2 deletions

View file

@ -623,6 +623,8 @@ class TagModule(BaseCliModule):
action="store_true",
help=("Use spec file version/release exactly as "
"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("--no-auto-changelog", action="store_true",
default=False,
@ -655,7 +657,9 @@ class TagModule(BaseCliModule):
None, None)
tagger_class = None
if self.pkg_config.has_option("buildconfig", "tagger"):
if self.options.use_version:
tagger_class = get_class_by_name("tito.tagger.ForceVersionTagger")
elif self.pkg_config.has_option("buildconfig", "tagger"):
tagger_class = get_class_by_name(self.pkg_config.get("buildconfig",
"tagger"))
else:
@ -673,6 +677,10 @@ class TagModule(BaseCliModule):
except TitoException, e:
error_out(e.message)
def _validate_options(self):
if self.options.keep_version and self.options.use_version:
error_out("Cannot combine --keep-version and --use-version")
class InitModule(BaseCliModule):
""" CLI Module for initializing a project for use with tito. """

View file

@ -89,6 +89,8 @@ class VersionTagger(object):
self._accept_auto_changelog=True
if options.auto_changelog_msg:
self._new_changelog_msg = options.auto_changelog_msg
if options.use_version:
self._use_version = options.use_version
# Only two paths through the tagger module right now:
if options.undo:
@ -303,7 +305,7 @@ class VersionTagger(object):
relative = current_dir[len(git_root) + 1:] + "/"
return relative
def _bump_version(self, release=False, zstream=False):
def _bump_version(self, release=False, zstream=False, force=False):
"""
Bump up the package version in the spec file.
@ -337,6 +339,20 @@ class VersionTagger(object):
, increase_zstream(match.group(2))
, "\n"
))
elif force:
match = re.match(version_regex, line)
if match:
line = "".join((match.group(1)
, 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:
@ -508,3 +524,20 @@ class ReleaseTagger(VersionTagger):
def release_type(self):
""" return short string "minor release" """
return "minor release"
class ForceVersionTagger(VersionTagger):
"""
Tagger which forcibly updates the spec file to a version provided on the
command line by the --use-version option.
"""
def _tag_release(self):
"""
Tag a new release of the package.
"""
self._make_changelog()
new_version = self._bump_version(force=True)
self._check_tag_does_not_exist(self._get_new_tag(new_version))
self._update_changelog(new_version)
self._update_setup_py(new_version)
self._update_package_metadata(new_version)

View file

@ -53,6 +53,10 @@ 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_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)
def test_undo_tag(self):
commit = self.repo.heads.master.commit
tito("tag --accept-auto-changelog --debug")