本文整理汇总了Python中vcstools.GitClient.get_current_version_label方法的典型用法代码示例。如果您正苦于以下问题:Python GitClient.get_current_version_label方法的具体用法?Python GitClient.get_current_version_label怎么用?Python GitClient.get_current_version_label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vcstools.GitClient
的用法示例。
在下文中一共展示了GitClient.get_current_version_label方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_current_version_label
# 需要导入模块: from vcstools import GitClient [as 别名]
# 或者: from vcstools.GitClient import get_current_version_label [as 别名]
def test_get_current_version_label(self):
client = GitClient(path=self.local_path)
# with detached local status
client.checkout(url=self.remote_path, version='test_tag')
self.assertEqual(client.get_current_version_label(), '<detached>')
# when difference between local and tracking branch
client.update(version='master')
self.assertEqual(client.get_current_version_label(), 'master')
# with other tracking branch
cmd = 'git config --replace-all branch.master.merge test_branch'
subprocess.check_call(cmd, shell=True, cwd=self.local_path)
self.assertEqual(client.get_current_version_label(),
'master < test_branch')
# with other remote
for cmd in [
'git remote add remote2 %s' % self.remote_path,
'git config --replace-all branch.master.remote remote2',
'git fetch remote2']:
subprocess.check_call(cmd, shell=True, cwd=self.local_path)
self.assertEqual(client.get_current_version_label(),
'master < remote2/test_branch')
# return remote back to original config
for cmd in [
'git config --replace-all branch.master.remote origin',
'git config --replace-all branch.master.merge refs/heads/master']:
subprocess.check_call(cmd, shell=True, cwd=self.local_path)