本文整理匯總了Python中vcstools.git.GitClient.get_diff方法的典型用法代碼示例。如果您正苦於以下問題:Python GitClient.get_diff方法的具體用法?Python GitClient.get_diff怎麽用?Python GitClient.get_diff使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vcstools.git.GitClient
的用法示例。
在下文中一共展示了GitClient.get_diff方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_diff
# 需要導入模塊: from vcstools.git import GitClient [as 別名]
# 或者: from vcstools.git.GitClient import get_diff [as 別名]
def test_diff(self):
url = self.remote_path
client = GitClient(self.local_path)
self.assertTrue(client.checkout(url))
output = client.get_diff()
self.assertEqual('', output, output)
with open(os.path.join(self.local_path, 'fixed.txt'), 'a') as f:
f.write('0123456789abcdef')
subprocess.check_call("touch new.txt", shell=True, cwd=self.local_path)
with open(os.path.join(self.sublocal_path, 'subfixed.txt'), 'a') as f:
f.write('abcdef0123456789')
subprocess.check_call("touch subnew.txt", shell=True, cwd=self.sublocal_path)
with open(os.path.join(self.subsublocal_path, 'subsubfixed.txt'), 'a') as f:
f.write('012345cdef')
subprocess.check_call("touch subsubnew.txt", shell=True, cwd=self.subsublocal_path)
output = client.get_diff()
self.assertEqual(1094, len(output))
self.assertTrue('diff --git ./fixed.txt ./fixed.txt\nindex e69de29..454f6b3 100644\n--- ./fixed.txt\n+++ ./fixed.txt\[email protected]@ -0,0 +1 @@\n+0123456789abcdef\n\\ No newline at end of file' in output)
self.assertTrue('diff --git ./submodule/subsubmodule/subsubfixed.txt ./submodule/subsubmodule/subsubfixed.txt\nindex e69de29..1a332dc 100644\n--- ./submodule/subsubmodule/subsubfixed.txt\n+++ ./submodule/subsubmodule/subsubfixed.txt\[email protected]@ -0,0 +1 @@\n+012345cdef\n\\ No newline at end of file' in output)
output = client.get_diff(basepath=os.path.dirname(self.local_path))
self.assertEqual(1174, len(output))
self.assertTrue('diff --git local/fixed.txt local/fixed.txt\nindex e69de29..454f6b3 100644\n--- local/fixed.txt\n+++ local/fixed.txt\[email protected]@ -0,0 +1 @@\n+0123456789abcdef\n\ No newline at end of file' in output, output)
self.assertTrue('diff --git local/submodule/subsubmodule/subsubfixed.txt local/submodule/subsubmodule/subsubfixed.txt\nindex e69de29..1a332dc 100644\n--- local/submodule/subsubmodule/subsubfixed.txt\n+++ local/submodule/subsubmodule/subsubfixed.txt\[email protected]@ -0,0 +1 @@\n+012345cdef\n\ No newline at end of file' in output, output)
示例2: testDiffRelpath
# 需要導入模塊: from vcstools.git import GitClient [as 別名]
# 或者: from vcstools.git.GitClient import get_diff [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)))