本文整理汇总了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)))