本文整理汇总了Python中vcstools.GitClient.get_remote_version方法的典型用法代码示例。如果您正苦于以下问题:Python GitClient.get_remote_version方法的具体用法?Python GitClient.get_remote_version怎么用?Python GitClient.get_remote_version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vcstools.GitClient
的用法示例。
在下文中一共展示了GitClient.get_remote_version方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_fetch_all_tags
# 需要导入模块: from vcstools import GitClient [as 别名]
# 或者: from vcstools.GitClient import get_remote_version [as 别名]
def test_update_fetch_all_tags(self):
url = self.remote_path
client = GitClient(self.local_path)
self.assertTrue(client.checkout(url, "master"))
self.assertEqual(client._get_branch(), "master")
self.assertEqual(client.get_remote_version(fetch=False), self.readonly_version)
self.assertEqual(client.get_remote_version(fetch=True), self.readonly_version)
subprocess.check_call("touch new_file.txt", shell=True, cwd=self.remote_path)
subprocess.check_call("git add *", shell=True, cwd=self.remote_path)
subprocess.check_call("git commit -m newfile", shell=True, cwd=self.remote_path)
po = subprocess.Popen("git log -n 1 --pretty=format:\"%H\"", shell=True, cwd=self.remote_path, stdout=subprocess.PIPE)
remote_new_version = po.stdout.read().decode('UTF-8').rstrip('"').lstrip('"')
self.assertNotEqual(self.readonly_version, remote_new_version)
# remote version stays same until we fetch
self.assertEqual(client.get_remote_version(fetch=False), self.readonly_version)
self.assertEqual(client.get_remote_version(fetch=True), remote_new_version)
self.assertEqual(client.get_remote_version(fetch=False), remote_new_version)
示例2: test_get_remote_version
# 需要导入模块: from vcstools import GitClient [as 别名]
# 或者: from vcstools.GitClient import get_remote_version [as 别名]
def test_get_remote_version(self):
url = self.remote_path
client = GitClient(path=self.local_path)
client.checkout(url, version='master')
self.assertEqual(client.get_remote_version(fetch=True), self.readonly_version)
self.assertEqual(client.get_remote_version(fetch=False), self.readonly_version)
subprocess.check_call("git reset --hard test_tag", shell=True, cwd=self.local_path)
self.assertEqual(client.get_remote_version(fetch=True), self.readonly_version)
client.update(version='test_branch')
self.assertEqual(client.get_remote_version(fetch=True), self.readonly_version_init)
client.update(version='test_branch')
self.assertEqual(client.get_remote_version(fetch=False), self.readonly_version_init)
# switch tracked branch
subprocess.check_call('git config --replace-all branch.master.merge test_branch', shell=True, cwd=self.local_path)
client.update(version='master')
self.assertEqual(client.get_remote_version(fetch=False), self.readonly_version_init)
# 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_remote_version(fetch=False), self.readonly_version_init)