本文整理汇总了Python中vcstools.git.GitClient.detect_presence方法的典型用法代码示例。如果您正苦于以下问题:Python GitClient.detect_presence方法的具体用法?Python GitClient.detect_presence怎么用?Python GitClient.detect_presence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vcstools.git.GitClient
的用法示例。
在下文中一共展示了GitClient.detect_presence方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_checkout_branch_with_subs
# 需要导入模块: from vcstools.git import GitClient [as 别名]
# 或者: from vcstools.git.GitClient import detect_presence [as 别名]
def test_checkout_branch_with_subs(self):
url = self.remote_path
client = GitClient(self.local_path)
subclient = GitClient(self.sublocal_path)
subsubclient = GitClient(self.subsublocal_path)
self.assertFalse(client.path_exists())
self.assertFalse(client.detect_presence())
self.assertTrue(client.checkout(url, refname='test_branch'))
self.assertTrue(client.path_exists())
self.assertTrue(client.detect_presence())
self.assertEqual(self.version_init, client.get_version())
self.assertFalse(subclient.path_exists())
示例2: test_export_master
# 需要导入模块: from vcstools.git import GitClient [as 别名]
# 或者: from vcstools.git.GitClient import detect_presence [as 别名]
def test_export_master(self):
url = self.remote_path
client = GitClient(self.local_path)
subclient = GitClient(self.sublocal_path)
subsubclient = GitClient(self.subsublocal_path)
self.assertFalse(client.path_exists())
self.assertFalse(client.detect_presence())
self.assertFalse(os.path.exists(self.export_path))
self.assertTrue(client.checkout(url))
self.assertTrue(client.path_exists())
self.assertTrue(subclient.path_exists())
self.assertTrue(subsubclient.path_exists())
tarpath = client.export_repository("master", self.export_path)
self.assertEqual(tarpath, self.export_path + '.tar.gz')
os.mkdir(self.export_path)
with closing(tarfile.open(tarpath, "r:gz")) as tarf:
tarf.extractall(self.export_path)
subsubdirdiff = filecmp.dircmp(self.subsubexport_path, self.subsublocal_path, ignore=['.git', '.gitmodules'])
self.assertEqual(subsubdirdiff.left_only, [])
self.assertEqual(subsubdirdiff.right_only, [])
self.assertEqual(subsubdirdiff.diff_files, [])
subdirdiff = filecmp.dircmp(self.subexport_path, self.sublocal_path, ignore=['.git', '.gitmodules'])
self.assertEqual(subdirdiff.left_only, [])
self.assertEqual(subdirdiff.right_only, [])
self.assertEqual(subdirdiff.diff_files, [])
dirdiff = filecmp.dircmp(self.export_path, self.local_path, ignore=['.git', '.gitmodules'])
self.assertEqual(dirdiff.left_only, [])
self.assertEqual(dirdiff.right_only, [])
self.assertEqual(dirdiff.diff_files, [])
示例3: test_switch_branches
# 需要导入模块: from vcstools.git import GitClient [as 别名]
# 或者: from vcstools.git.GitClient import detect_presence [as 别名]
def test_switch_branches(self):
url = self.remote_path
client = GitClient(self.local_path)
subclient = GitClient(self.sublocal_path)
subclient2 = GitClient(self.sublocal2_path)
subsubclient = GitClient(self.subsublocal_path)
subsubclient2 = GitClient(self.subsublocal2_path)
self.assertFalse(client.path_exists())
self.assertFalse(client.detect_presence())
self.assertTrue(client.checkout(url))
self.assertTrue(client.path_exists())
self.assertTrue(subclient.path_exists())
self.assertTrue(subsubclient.path_exists())
self.assertFalse(subclient2.path_exists())
new_version = "test_branch"
self.assertTrue(client.update(new_version))
# checking that update doesnt make submodule disappear (git default behavior)
self.assertTrue(subclient2.path_exists())
self.assertTrue(subsubclient2.path_exists())
self.assertTrue(subclient.path_exists())
self.assertTrue(subsubclient.path_exists())
oldnew_version = "master"
self.assertTrue(client.update(oldnew_version))
# checking that update doesnt make submodule2 disappear (git default behavior)
self.assertTrue(subclient2.path_exists())
self.assertTrue(subsubclient2.path_exists())
self.assertTrue(subclient.path_exists())
self.assertTrue(subsubclient.path_exists())
示例4: test_checkout_master_with_subs
# 需要导入模块: from vcstools.git import GitClient [as 别名]
# 或者: from vcstools.git.GitClient import detect_presence [as 别名]
def test_checkout_master_with_subs(self):
url = self.remote_path
client = GitClient(self.local_path)
subclient = GitClient(self.sublocal_path)
subsubclient = GitClient(self.subsublocal_path)
self.assertFalse(client.path_exists())
self.assertFalse(client.detect_presence())
self.assertTrue(client.checkout(url))
self.assertTrue(client.path_exists())
self.assertTrue(client.detect_presence())
self.assertEqual(self.version_final, client.get_version())
self.assertTrue(subclient.path_exists())
self.assertTrue(subclient.detect_presence())
self.assertEqual(self.subversion_final, subclient.get_version())
self.assertTrue(subsubclient.path_exists())
self.assertTrue(subsubclient.detect_presence())
self.assertEqual(self.subsubversion_final, subsubclient.get_version())
示例5: test_get_url_by_reading
# 需要导入模块: from vcstools.git import GitClient [as 别名]
# 或者: from vcstools.git.GitClient import detect_presence [as 别名]
def test_get_url_by_reading(self):
from vcstools.git import GitClient
client = GitClient(self.readonly_path)
self.assertTrue(client.path_exists())
self.assertTrue(client.detect_presence())
self.assertEqual(client.get_url(), self.readonly_url)
self.assertEqual(client.get_version(), self.readonly_version)
self.assertEqual(client.get_version(self.readonly_version_init[0:6]), self.readonly_version_init)
self.assertEqual(client.get_version("test_tag"), self.readonly_version_init)
示例6: test_checkout
# 需要导入模块: from vcstools.git import GitClient [as 别名]
# 或者: from vcstools.git.GitClient import detect_presence [as 别名]
def test_checkout(self):
from vcstools.git import GitClient
directory = tempfile.mkdtemp()
self.directories["checkout_test"] = directory
local_path = os.path.join(directory, "ros")
url = self.readonly_url
client = GitClient(local_path)
self.assertFalse(client.path_exists())
self.assertFalse(client.detect_presence())
self.assertFalse(client.detect_presence())
self.assertTrue(client.checkout(url))
self.assertTrue(client.path_exists())
self.assertTrue(client.detect_presence())
self.assertEqual(client.get_path(), local_path)
self.assertEqual(client.get_url(), url)
self.assertEqual(client.get_branch(), "master")
self.assertEqual(client.get_branch_parent(), "master")
#self.assertEqual(client.get_version(), '-r*')
shutil.rmtree(directory)
self.directories.pop("checkout_test")
示例7: test_export_hash
# 需要导入模块: from vcstools.git import GitClient [as 别名]
# 或者: from vcstools.git.GitClient import detect_presence [as 别名]
def test_export_hash(self):
url = self.remote_path
client = GitClient(self.local_path)
subclient = GitClient(self.sublocal_path)
subclient2 = GitClient(self.sublocal2_path)
subsubclient = GitClient(self.subsublocal_path)
subsubclient2 = GitClient(self.subsublocal2_path)
self.assertFalse(client.path_exists())
self.assertFalse(client.detect_presence())
self.assertFalse(os.path.exists(self.export_path))
self.assertTrue(client.checkout(url, version='master'))
self.assertTrue(client.path_exists())
self.assertTrue(subclient.path_exists())
self.assertTrue(subsubclient.path_exists())
self.assertFalse(subclient2.path_exists())
self.assertFalse(subsubclient2.path_exists())
# we need first to retrieve locally the hash we want to export
self.assertTrue(client.update(version=self.version_test))
self.assertTrue(client.path_exists())
# git leaves old submodule around by default
self.assertTrue(subclient.path_exists())
self.assertTrue(subsubclient.path_exists())
# new submodule should be there
self.assertTrue(subclient2.path_exists())
self.assertTrue(subsubclient2.path_exists())
tarpath = client.export_repository(self.version_test, self.export_path)
self.assertEqual(tarpath, self.export_path + '.tar.gz')
os.mkdir(self.export_path)
with closing(tarfile.open(tarpath, "r:gz")) as tarf:
tarf.extractall(self.export_path)
# Checking that we have only submodule2 in our export
self.assertFalse(os.path.exists(self.subexport_path))
self.assertFalse(os.path.exists(self.subsubexport_path))
self.assertTrue(os.path.exists(self.subexport2_path))
self.assertTrue(os.path.exists(self.subsubexport2_path))
# comparing with version_test ( currently checked-out )
subsubdirdiff = filecmp.dircmp(self.subsubexport2_path, self.subsublocal_path, ignore=['.git', '.gitmodules'])
self.assertEqual(subsubdirdiff.left_only, []) # same subsubfixed.txt in both subsubmodule/
self.assertEqual(subsubdirdiff.right_only, [])
self.assertEqual(subsubdirdiff.diff_files, [])
subdirdiff = filecmp.dircmp(self.subexport2_path, self.sublocal_path, ignore=['.git', '.gitmodules'])
self.assertEqual(subdirdiff.left_only, [])
self.assertEqual(subdirdiff.right_only, [])
self.assertEqual(subdirdiff.diff_files, [])
dirdiff = filecmp.dircmp(self.export_path, self.local_path, ignore=['.git', '.gitmodules'])
self.assertEqual(dirdiff.left_only, [])
# submodule is still there on local_path (git default behavior)
self.assertEqual(dirdiff.right_only, ['submodule'])
self.assertEqual(dirdiff.diff_files, [])
示例8: test_checkout_specific_branch_and_update
# 需要导入模块: from vcstools.git import GitClient [as 别名]
# 或者: from vcstools.git.GitClient import detect_presence [as 别名]
def test_checkout_specific_branch_and_update(self):
from vcstools.git import GitClient
directory = tempfile.mkdtemp()
subdir = "checkout_specific_version_test"
self.directories[subdir] = directory
local_path = os.path.join(directory, "ros")
url = self.readonly_url
branch = "master"
client = GitClient(local_path)
self.assertFalse(client.path_exists())
self.assertFalse(client.detect_presence())
self.assertTrue(client.checkout(url, branch))
self.assertTrue(client.path_exists())
self.assertTrue(client.detect_presence())
self.assertEqual(client.get_path(), local_path)
self.assertEqual(client.get_url(), url)
self.assertEqual(client.get_branch_parent(), branch)
new_branch = 'master'
self.assertTrue(client.update(new_branch))
self.assertEqual(client.get_branch_parent(), new_branch)
shutil.rmtree(directory)
self.directories.pop(subdir)
示例9: test_switch_branches
# 需要导入模块: from vcstools.git import GitClient [as 别名]
# 或者: from vcstools.git.GitClient import detect_presence [as 别名]
def test_switch_branches(self):
url = self.remote_path
client = GitClient(self.local_path)
subclient = GitClient(self.sublocal_path)
subclient2 = GitClient(self.sublocal2_path)
subsubclient = GitClient(self.subsublocal_path)
self.assertFalse(client.path_exists())
self.assertFalse(client.detect_presence())
self.assertTrue(client.checkout(url))
self.assertTrue(client.path_exists())
self.assertTrue(subclient.path_exists())
self.assertTrue(subsubclient.path_exists())
self.assertFalse(subclient2.path_exists())
new_version = "test_branch2"
self.assertTrue(client.update(new_version))
self.assertTrue(subclient2.path_exists())
示例10: test_switch_branches_retrieve_local_subcommit
# 需要导入模块: from vcstools.git import GitClient [as 别名]
# 或者: from vcstools.git.GitClient import detect_presence [as 别名]
def test_switch_branches_retrieve_local_subcommit(self):
url = self.remote_path
client = GitClient(self.local_path)
subclient = GitClient(self.sublocal_path)
subclient2 = GitClient(self.sublocal2_path)
subsubclient = GitClient(self.subsublocal_path)
subsubclient2 = GitClient(self.subsublocal2_path)
self.assertFalse(client.path_exists())
self.assertFalse(client.detect_presence())
self.assertTrue(client.checkout(url))
self.assertTrue(client.path_exists())
self.assertTrue(subclient.path_exists())
self.assertTrue(subsubclient.path_exists())
self.assertFalse(subclient2.path_exists())
new_version = "test_branch"
self.assertTrue(client.update(new_version))
# checking that update doesnt make submodule disappear (git default behavior)
self.assertTrue(subclient2.path_exists())
self.assertTrue(subsubclient2.path_exists())
self.assertTrue(subclient.path_exists())
self.assertTrue(subsubclient.path_exists())
subprocess.check_call("touch submodif.txt", shell=True, cwd=self.sublocal2_path)
subprocess.check_call("git add submodif.txt", shell=True, cwd=self.sublocal2_path)
subprocess.check_call("git commit -m submodif", shell=True, cwd=self.sublocal2_path)
subprocess.check_call("git add submodule2", shell=True, cwd=self.local_path)
subprocess.check_call("git commit -m submodule2_modif", shell=True, cwd=self.local_path)
oldnew_version = "master"
self.assertTrue(client.update(oldnew_version))
# checking that update doesnt make submodule2 disappear (git default behavior)
self.assertTrue(subclient2.path_exists())
self.assertTrue(subsubclient2.path_exists())
self.assertTrue(subclient.path_exists())
self.assertTrue(subsubclient.path_exists())
self.assertTrue(client.update(new_version))
# checking that update still has submodule with submodif
self.assertTrue(subclient2.path_exists())
self.assertTrue(subsubclient2.path_exists())
self.assertTrue(subclient.path_exists())
self.assertTrue(subsubclient.path_exists())
self.assertTrue(os.path.exists(os.path.join(self.sublocal2_path, "submodif.txt")))
示例11: testStatusUntracked
# 需要导入模块: from vcstools.git import GitClient [as 别名]
# 或者: from vcstools.git.GitClient import detect_presence [as 别名]
def testStatusUntracked(self):
from vcstools.git import GitClient
client = GitClient(self.readonly_path)
self.assertTrue(client.path_exists())
self.assertTrue(client.detect_presence())
self.assertEquals('A ./added.txt\n D ./deleted-fs.txt\nD ./deleted.txt\n M ./modified-fs.txt\nM ./modified.txt\n?? ./added-fs.txt\n', client.get_status(untracked=True))
示例12: testStatusRelPath
# 需要导入模块: from vcstools.git import GitClient [as 别名]
# 或者: from vcstools.git.GitClient import detect_presence [as 别名]
def testStatusRelPath(self):
from vcstools.git import GitClient
client = GitClient(self.readonly_path)
self.assertTrue(client.path_exists())
self.assertTrue(client.detect_presence())
self.assertEquals('A readonly/added.txt\n D readonly/deleted-fs.txt\nD readonly/deleted.txt\n M readonly/modified-fs.txt\nM readonly/modified.txt\n', client.get_status(basepath=os.path.dirname(self.readonly_path)))
示例13: testDiffRelpath
# 需要导入模块: from vcstools.git import GitClient [as 别名]
# 或者: from vcstools.git.GitClient import detect_presence [as 别名]
def testDiffRelpath(self):
from vcstools.git import GitClient
client = GitClient(self.readonly_path)
self.assertTrue(client.path_exists())
self.assertTrue(client.detect_presence())
self.assertEquals('diff --git readonly/added.txt readonly/added.txt\nnew file mode 100644\nindex 0000000..454f6b3\n--- /dev/null\n+++ readonly/added.txt\[email protected]@ -0,0 +1 @@\n+0123456789abcdef\n\\ No newline at end of file\ndiff --git readonly/deleted-fs.txt readonly/deleted-fs.txt\ndeleted file mode 100644\nindex e69de29..0000000\ndiff --git readonly/deleted.txt readonly/deleted.txt\ndeleted file mode 100644\nindex e69de29..0000000\ndiff --git readonly/modified-fs.txt readonly/modified-fs.txt\nindex e69de29..454f6b3 100644\n--- readonly/modified-fs.txt\n+++ readonly/modified-fs.txt\[email protected]@ -0,0 +1 @@\n+0123456789abcdef\n\\ No newline at end of file\ndiff --git readonly/modified.txt readonly/modified.txt\nindex e69de29..454f6b3 100644\n--- readonly/modified.txt\n+++ readonly/modified.txt\[email protected]@ -0,0 +1 @@\n+0123456789abcdef\n\\ No newline at end of file\n', client.get_diff(basepath=os.path.dirname(self.readonly_path)))