本文整理汇总了Python中tito.common.get_latest_tagged_version函数的典型用法代码示例。如果您正苦于以下问题:Python get_latest_tagged_version函数的具体用法?Python get_latest_tagged_version怎么用?Python get_latest_tagged_version使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_latest_tagged_version函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_release_tagger_use_version
def test_release_tagger_use_version(self):
os.chdir(os.path.join(self.repo_dir, 'pkg2'))
start_ver = get_latest_tagged_version(TEST_PKG_2)
tito('tag --debug --accept-auto-changelog --use-version 1.3.37')
new_ver = get_latest_tagged_version(TEST_PKG_2)
self.assertFalse(release_bumped(start_ver, new_ver))
self.assertEquals(new_ver, "1.3.37-1")
示例2: test_release_tagger_legacy_props_file
def test_release_tagger_legacy_props_file(self):
# Test that build.py.props filename is still picked up:
os.chdir(os.path.join(MULTI_GIT, TEST_PKG_2_DIR))
start_ver = get_latest_tagged_version(TEST_PKG_2)
run_command("git mv tito.props build.py.props")
run_command('git commit -a -m "Rename to build.py.props"')
run_tito('tag --debug --accept-auto-changelog')
new_ver = get_latest_tagged_version(TEST_PKG_2)
self.assertTrue(release_bumped(start_ver, new_ver))
示例3: test_release_tagger_legacy_props_file
def test_release_tagger_legacy_props_file(self):
# Test that build.py.props filename is still picked up:
os.chdir(os.path.join(self.repo_dir, 'pkg2'))
start_ver = get_latest_tagged_version(TEST_PKG_2)
run_command("git mv tito.props build.py.props")
index = self.repo.index
index.add(['pkg2/build.py.props'])
index.commit("Rename to build.py.props.")
tito('tag --debug --accept-auto-changelog')
new_ver = get_latest_tagged_version(TEST_PKG_2)
self.assertTrue(release_bumped(start_ver, new_ver))
示例4: _get_build_version
def _get_build_version(self):
"""
Figure out the git tag and version-release we're building.
"""
# Determine which package version we should build:
build_version = None
if self.build_tag:
build_version = self.build_tag[len(self.project_name + "-"):]
else:
build_version = get_latest_tagged_version(self.project_name)
if build_version is None:
if not self.test:
error_out(["Unable to lookup latest package info.",
"Perhaps you need to tag first?"])
warn_out("unable to lookup latest package "
"tag, building untagged test project")
build_version = get_spec_version_and_release(self.start_dir,
find_spec_like_file(self.start_dir))
self.build_tag = "%s-%s" % (self.project_name, build_version)
self.spec_version = build_version.split('-')[-2]
self.spec_release = build_version.split('-')[-1]
if not self.test:
check_tag_exists(self.build_tag, offline=self.offline)
return build_version
示例5: main
def main(self):
BaseCliModule.main(self)
build_dir = os.path.normpath(os.path.abspath(self.options.output_dir))
package_name = get_project_name(tag=self.options.tag)
build_tag = None
build_version = None
# Determine which package version we should build:
if self.options.tag:
build_tag = self.options.tag
build_version = build_tag[len(package_name + "-"):]
else:
build_version = get_latest_tagged_version(package_name)
if build_version == None:
error_out(["Unable to lookup latest package info.",
"Perhaps you need to tag first?"])
build_tag = "%s-%s" % (package_name, build_version)
if not self.options.test:
check_tag_exists(build_tag, offline=self.options.offline)
self.pkg_config = self._read_project_config(package_name, build_dir,
self.options.tag, self.options.no_cleanup)
builder = self._create_builder(package_name, build_tag,
build_version, self.options, self.pkg_config,
build_dir)
builder.run(self.options)
示例6: test_template_version_tagger
def test_template_version_tagger(self):
"""
Make sure the template is applied and results in the correct file
being included in the tag.
"""
pkg_dir = join(self.repo_dir, 'pkg3')
filename = join(pkg_dir, "tito.props")
self.write_file(filename, TEMPLATE_TAGGER_TITO_PROPS)
run_command('mkdir -p %s' % join(self.repo_dir, '.tito/templates'))
self.write_file(join(self.repo_dir,
'.tito/templates/version.rb'), VERSION_TEMPLATE_FILE)
os.chdir(self.repo_dir)
run_command('git add pkg3/tito.props')
run_command("git commit -m 'add tito.props for pkg3'")
# Create another pkg3 tag and make sure we got a generated
# template file.
os.chdir(os.path.join(self.repo_dir, 'pkg3'))
tito('tag --debug --accept-auto-changelog')
new_ver = get_latest_tagged_version(TEST_PKG_3)
self.assertEquals("0.0.2-1", new_ver)
dest_file = os.path.join(self.repo_dir, 'pkg3', "version.txt")
self.assertTrue(os.path.exists(dest_file))
f = open(dest_file, 'r')
contents = f.read()
f.close()
self.assertTrue("VERSION = \"0.0.2-1\"" in contents)
示例7: _bump_version
def _bump_version(self, release=False, zstream=False):
"""
Bump up the package version in the spec file.
Set release to True to bump the package release instead.
Checks for the keep version option and if found, won't actually
bump the version or release.
"""
old_version = get_latest_tagged_version(self.project_name)
if old_version == None:
old_version = "untagged"
# TODO: Do this here instead of calling out to an external Perl script:
if not self.keep_version:
bump_type = "bump-version"
if release:
bump_type = "bump-release"
elif zstream:
bump_type = "bump-zstream"
script_path = get_script_path("bump-version.pl")
cmd = "%s %s --specfile %s" % \
(script_path, bump_type, self.spec_file)
run_command(cmd)
new_version = self._get_spec_version_and_release()
if new_version.strip() == "":
msg = "Error getting bumped package version, try: \n"
msg = msg + " 'rpm -q --specfile %s'" % self.spec_file
error_out(msg)
print("Tagging new version of %s: %s -> %s" % (self.project_name,
old_version, new_version))
return new_version
示例8: _bump_version
def _bump_version(self, release=False, zstream=False):
"""
Bump up the package version in the spec file.
Set release to True to bump the package release instead.
Checks for the keep version option and if found, won't actually
bump the version or release.
"""
old_version = get_latest_tagged_version(self.project_name)
if old_version is None:
old_version = "untagged"
if not self.keep_version:
version_regex = re.compile("^(version:\s*)(.+)$", re.IGNORECASE)
release_regex = re.compile("^(release:\s*)(.+)$", re.IGNORECASE)
in_f = open(self.spec_file, 'r')
out_f = open(self.spec_file + ".new", 'w')
for line in in_f.readlines():
version_match = re.match(version_regex, line)
release_match = re.match(release_regex, line)
if version_match and not zstream and not release:
current_version = version_match.group(2)
if hasattr(self, '_use_version'):
updated_content = self._use_version
else:
updated_content = increase_version(current_version)
line = "".join([version_match.group(1), updated_content, "\n"])
elif release_match:
current_release = release_match.group(2)
if hasattr(self, '_use_release'):
updated_content = self._use_release
elif release:
updated_content = increase_version(current_release)
elif zstream:
updated_content = increase_zstream(current_release)
else:
updated_content = reset_release(current_release)
line = "".join([release_match.group(1), updated_content, "\n"])
out_f.write(line)
in_f.close()
out_f.close()
shutil.move(self.spec_file + ".new", self.spec_file)
new_version = get_spec_version_and_release(self.full_project_dir,
self.spec_file_name)
if new_version.strip() == "":
msg = "Error getting bumped package version, try: \n"
msg = msg + " 'rpm -q --specfile %s'" % self.spec_file
error_out(msg)
info_out("Tagging new version of %s: %s -> %s" % (self.project_name,
old_version, new_version))
return new_version
示例9: run
def run(self, options):
"""
Tag using the (platform) project as master for the version.
@param options: tagging options.
@type options: options
"""
tag = get_latest_tagged_version(MASTER_PACKAGE)
options.use_version = tag.split('-', 1)[0]
PulpTagger.run(self, options)
示例10: next
def next(project='pulp'):
"""
Get the next (incremented) version or release.
@param project: A pulp project name.
@type project: str
@return: The version-release
@rtype: str
"""
last_version = get_latest_tagged_version(project)
return increment(last_version)
示例11: _get_build_version
def _get_build_version(self):
"""
Figure out the git tag and version-release we're building.
"""
# Determine which package version we should build:
build_version = None
if self.build_tag:
build_version = self.build_tag[len(self.project_name + "-"):]
else:
build_version = get_latest_tagged_version(self.project_name)
if build_version is None:
error_out(["Unable to lookup latest package info.",
"Perhaps you need to tag first?"])
self.build_tag = "%s-%s" % (self.project_name, build_version)
if not self.test:
check_tag_exists(self.build_tag, offline=self.offline)
return build_version
示例12: _get_build_version
def _get_build_version(self):
"""
Figure out the git tag and version-release we're building.
"""
# Determine which package version we should build:
build_version = None
if self.build_tag:
build_version = self.build_tag[len(self.project_name + "-") :]
else:
build_version = get_latest_tagged_version(self.project_name)
if build_version is None:
if not self.test:
error_out(["Unable to lookup latest package info.", "Perhaps you need to tag first?"])
sys.stderr.write("WARNING: unable to lookup latest package " "tag, building untagged test project\n")
build_version = get_spec_version_and_release(self.start_dir, find_spec_file(in_dir=self.start_dir))
self.build_tag = "v{0}".format(build_version)
if not self.test:
check_tag_exists(self.build_tag, offline=self.offline)
return build_version
示例13: _undo
def _undo(self):
"""
Undo the most recent tag.
Tag commit must be the most recent commit, and the tag must not
exist in the remote git repo, otherwise we report and error out.
"""
tag = "v{0}".format(get_latest_tagged_version(self.project_name))
print("Undoing tag: {0}".format(tag))
if not tag_exists_locally(tag):
raise TitoException(
"Cannot undo tag that does not exist locally.")
if not self.offline and tag_exists_remotely(tag):
raise TitoException("Cannot undo tag that has been pushed.")
# Tag must be the most recent commit.
if not head_points_to_tag(tag):
raise TitoException("Cannot undo if tag is not the most recent commit.")
# Everything looks good:
print
undo_tag(tag)
示例14: test_release_tagger_use_release
def test_release_tagger_use_release(self):
os.chdir(os.path.join(self.repo_dir, 'pkg2'))
tito('tag --debug --accept-auto-changelog --use-release 42')
new_ver = get_latest_tagged_version(TEST_PKG_2)
self.assertEquals(new_ver.split('-')[-1], "42")
示例15: test_release_tagger
def test_release_tagger(self):
os.chdir(os.path.join(self.repo_dir, 'pkg2'))
start_ver = get_latest_tagged_version(TEST_PKG_2)
tito('tag --debug --accept-auto-changelog')
new_ver = get_latest_tagged_version(TEST_PKG_2)
self.assertTrue(release_bumped(start_ver, new_ver))