本文整理汇总了Python中vcstools.git.GitClient.export_repository方法的典型用法代码示例。如果您正苦于以下问题:Python GitClient.export_repository方法的具体用法?Python GitClient.export_repository怎么用?Python GitClient.export_repository使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vcstools.git.GitClient
的用法示例。
在下文中一共展示了GitClient.export_repository方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_export_master
# 需要导入模块: from vcstools.git import GitClient [as 别名]
# 或者: from vcstools.git.GitClient import export_repository [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, [])
示例2: test_export_hash
# 需要导入模块: from vcstools.git import GitClient [as 别名]
# 或者: from vcstools.git.GitClient import export_repository [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, [])