本文整理匯總了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, [])