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\n@@ -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\n@@ -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\n@@ -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\n@@ -0,0 +1 @@\n+012345cdef\n\ No newline at end of file' in output, output)
def test_diff(self): url = self.repo_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') _touch(os.path.join(self.local_path, "new.txt")) with open(os.path.join(self.sublocal_path, 'subfixed.txt'), 'a') as f: f.write('abcdef0123456789') _touch(os.path.join(self.sublocal_path, "subnew.txt")) with open(os.path.join(self.subsublocal_path, 'subsubfixed.txt'), 'a') as f: f.write('012345cdef') _touch(os.path.join(self.subsublocal_path, "subsubnew.txt")) output = client.get_diff() self.assertEqual(1094, len(output)) self.assertTrue('''\ diff --git ./fixed.txt ./fixed.txt index e69de29..454f6b3 100644 --- ./fixed.txt +++ ./fixed.txt @@ -0,0 +1 @@ +0123456789abcdef \\ No newline at end of file''' in output) self.assertTrue('''\ diff --git ./submodule/subsubmodule/subsubfixed.txt ./submodule/subsubmodule/subsubfixed.txt index e69de29..1a332dc 100644 --- ./submodule/subsubmodule/subsubfixed.txt +++ ./submodule/subsubmodule/subsubfixed.txt @@ -0,0 +1 @@ +012345cdef \\ 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 index e69de29..454f6b3 100644 --- local/fixed.txt +++ local/fixed.txt @@ -0,0 +1 @@ +0123456789abcdef \ No newline at end of file''' in output, output) self.assertTrue(''' diff --git local/submodule/subsubmodule/subsubfixed.txt local/submodule/subsubmodule/subsubfixed.txt index e69de29..1a332dc 100644 --- local/submodule/subsubmodule/subsubfixed.txt +++ local/submodule/subsubmodule/subsubfixed.txt @@ -0,0 +1 @@ +012345cdef \ No newline at end of file''' in output, output)
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\n@@ -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\n@@ -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\n@@ -0,0 +1 @@\n+0123456789abcdef\n\\ No newline at end of file\n', client.get_diff(basepath=os.path.dirname(self.readonly_path)))
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\n@@ -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\n@@ -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\n@@ -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\n@@ -0,0 +1 @@\n+012345cdef\n\ No newline at end of file' in output, output)
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\n@@ -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\n@@ -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\n@@ -0,0 +1 @@\n+0123456789abcdef\n\\ No newline at end of file\n', client.get_diff(basepath=os.path.dirname(self.readonly_path)))