def test_status(self): url = self.remote_path client = GitClient(self.local_path) self.assertTrue(client.checkout(url)) output = client.get_status() 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_status() self.assertEqual(' M ./fixed.txt\n M ./submodule\n M ./subfixed.txt\n M ./subsubmodule\n M ./subsubfixed.txt', output.rstrip()) output = client.get_status(untracked = True) self.assertEqual(' M ./fixed.txt\n M ./submodule\n?? ./new.txt\n M ./subfixed.txt\n M ./subsubmodule\n?? ./subnew.txt\n M ./subsubfixed.txt\n?? ./subsubnew.txt', output.rstrip()) output = client.get_status(basepath=os.path.dirname(self.local_path), untracked = True) self.assertEqual(' M local/fixed.txt\n M local/submodule\n?? local/new.txt\n M local/subfixed.txt\n M local/subsubmodule\n?? local/subnew.txt\n M local/subsubfixed.txt\n?? local/subsubnew.txt', output.rstrip())
def test_status(self): url = self.repo_path client = GitClient(self.local_path) self.assertTrue(client.checkout(url)) output = client.get_status( porcelain=True) # porcelain=True ensures stable format self.assertEqual('', output, "Expected empty string, got `{0}`".format(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_status( porcelain=True) # porcelain=True ensures stable format self.assertEqual( '''\ M ./fixed.txt M ./submodule M ./subfixed.txt M ./subsubmodule M ./subsubfixed.txt''', output.rstrip()) output = client.get_status(untracked=True, porcelain=True) self.assertEqual( '''\ M ./fixed.txt M ./submodule ?? ./new.txt M ./subfixed.txt M ./subsubmodule ?? ./subnew.txt M ./subsubfixed.txt ?? ./subsubnew.txt''', output.rstrip()) output = client.get_status(basepath=os.path.dirname(self.local_path), untracked=True, porcelain=True) self.assertEqual( '''\ M local/fixed.txt M local/submodule ?? local/new.txt M local/subfixed.txt M local/subsubmodule ?? local/subnew.txt M local/subsubfixed.txt ?? local/subsubnew.txt''', output.rstrip())
def test_status(self): url = self.repo_path client = GitClient(self.local_path) self.assertTrue(client.checkout(url)) output = client.get_status(porcelain=True) # porcelain=True ensures stable format self.assertEqual('', output, "Expected empty string, got `{0}`".format(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_status(porcelain=True) # porcelain=True ensures stable format self.assertEqual('''\ M ./fixed.txt M ./submodule M ./subfixed.txt M ./subsubmodule M ./subsubfixed.txt''', output.rstrip()) output = client.get_status(untracked=True, porcelain=True) self.assertEqual('''\ M ./fixed.txt M ./submodule ?? ./new.txt M ./subfixed.txt M ./subsubmodule ?? ./subnew.txt M ./subsubfixed.txt ?? ./subsubnew.txt''', output.rstrip()) output = client.get_status( basepath=os.path.dirname(self.local_path), untracked=True, porcelain=True) self.assertEqual('''\ M local/fixed.txt M local/submodule ?? local/new.txt M local/subfixed.txt M local/subsubmodule ?? local/subnew.txt M local/subsubfixed.txt ?? local/subsubnew.txt''', output.rstrip())
def testStatusUntracked(self): from vcstools.git import GitClient client = GitClient(self.readonly_path) self.assertTrue(client.path_exists()) self.assertTrue(client.detect_presence()) self.assertEquals( 'A ./added.txt\n D ./deleted-fs.txt\nD ./deleted.txt\n M ./modified-fs.txt\nM ./modified.txt\n?? ./added-fs.txt\n', client.get_status(untracked=True))
def testStatusRelPath(self): from vcstools.git import GitClient client = GitClient(self.readonly_path) self.assertTrue(client.path_exists()) self.assertTrue(client.detect_presence()) self.assertEquals( 'A readonly/added.txt\n D readonly/deleted-fs.txt\nD readonly/deleted.txt\n M readonly/modified-fs.txt\nM readonly/modified.txt\n', client.get_status(basepath=os.path.dirname(self.readonly_path)))
def test_status(self): url = self.remote_path client = GitClient(self.local_path) self.assertTrue(client.checkout(url)) output = client.get_status() 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_status() self.assertEqual( ' M ./fixed.txt\n M ./submodule\n M ./subfixed.txt\n M ./subsubmodule\n M ./subsubfixed.txt', output.rstrip()) output = client.get_status(untracked=True) self.assertEqual( ' M ./fixed.txt\n M ./submodule\n?? ./new.txt\n M ./subfixed.txt\n M ./subsubmodule\n?? ./subnew.txt\n M ./subsubfixed.txt\n?? ./subsubnew.txt', output.rstrip()) output = client.get_status(basepath=os.path.dirname(self.local_path), untracked=True) self.assertEqual( ' M local/fixed.txt\n M local/submodule\n?? local/new.txt\n M local/subfixed.txt\n M local/subsubmodule\n?? local/subnew.txt\n M local/subsubfixed.txt\n?? local/subsubnew.txt', output.rstrip())
def testStatusUntracked(self): from vcstools.git import GitClient client = GitClient(self.readonly_path) self.assertTrue(client.path_exists()) self.assertTrue(client.detect_presence()) self.assertEquals('A ./added.txt\n D ./deleted-fs.txt\nD ./deleted.txt\n M ./modified-fs.txt\nM ./modified.txt\n?? ./added-fs.txt\n', client.get_status(untracked=True))
def testStatusRelPath(self): from vcstools.git import GitClient client = GitClient(self.readonly_path) self.assertTrue(client.path_exists()) self.assertTrue(client.detect_presence()) self.assertEquals('A readonly/added.txt\n D readonly/deleted-fs.txt\nD readonly/deleted.txt\n M readonly/modified-fs.txt\nM readonly/modified.txt\n', client.get_status(basepath=os.path.dirname(self.readonly_path)))