def test_apply_cached(): with open(clone_path + '/README.mdown', 'w') as f: f.write('New readme') # Get the initial diff. diff = git.diff(clone_path) git.apply_cached(clone_path, diff) # Changes have been staged, diff result should be empty. diff = git.diff(clone_path) eq_(diff, '')
def test_apply_cached(self): with open(clone_path + '/README.mdown', 'w') as f: f.write('New readme') # Get the initial diff. diff = git.diff(clone_path) git.apply_cached(clone_path, diff) # Changes have been staged, diff result should be empty. diff = git.diff(clone_path) self.assertEqual(diff, '')
def test_diff(): with open(clone_path + '/README.mdown', 'w') as f: f.write('New readme') result = git.diff(clone_path) assert_in('a/README.mdown', result) assert_in('b/README.mdown', result) assert_in('+New readme', result) assert_in('-# Lint Review', result)
def test_diff(self): with open(clone_path + '/README.mdown', 'w') as f: f.write('New readme') result = git.diff(clone_path) self.assertIn('a/README.mdown', result) self.assertIn('b/README.mdown', result) self.assertIn('+New readme', result) self.assertIn('-# Lint Review', result)
def test_commit_and_status(): with open(clone_path + '/README.mdown', 'w') as f: f.write('New readme') diff = git.diff(clone_path) status = git.status(clone_path) assert 'README.mdown' in status git.apply_cached(clone_path, diff) git.commit(clone_path, 'robot <*****@*****.**>', 'Fixed readme') status = git.status(clone_path) eq_('', status, 'No changes unstaged, or uncommitted')
def test_commit_and_status(self): with open(clone_path + '/README.mdown', 'w') as f: f.write('New readme') diff = git.diff(clone_path) status = git.status(clone_path) assert 'README.mdown' in status git.apply_cached(clone_path, diff) git.commit(clone_path, 'robot <*****@*****.**>', 'Fixed readme') status = git.status(clone_path) self.assertEqual('', status, 'No changes unstaged, or uncommitted')
def run_fixers(tools, base_path, files): """Run fixer mode of each tool on each file Return a DiffCollection based on the parsed diff from the fixer changes. If no diff is generated an empty list will be returned""" log.info('Running fixers on %d files', len(files)) for tool in tools: if tool.has_fixer(): tool.execute_fixer(files) diff = git.diff(base_path, files) if diff: return parse_diff(diff) return []
def run_fixers(tools, base_path, files): """Run fixer mode of each tool on each file Return a DiffCollection based on the parsed diff from the fixer changes. If no diff is generated an empty list will be returned""" log.info('Running fixers on %d files', len(files)) docker_files = [docker.apply_base(f) for f in files] for tool in tools: if tool.has_fixer(): tool.execute_fixer(docker_files) diff = git.diff(base_path, files) if diff: return parse_diff(diff) return []
def test_apply_cached__empty(): git.apply_cached(clone_path, '') # No changes, no diff. diff = git.diff(clone_path) eq_(diff, '')
def test_diff__non_git_path(): git.diff(settings['WORKSPACE'] + '/../../')
def test_apply_cached__empty(self): git.apply_cached(clone_path, '') # No changes, no diff. diff = git.diff(clone_path) self.assertEqual(diff, '')
def test_diff__files_list(self): with open(clone_path + '/README.mdown', 'w') as f: f.write('New readme') result = git.diff(clone_path, ['LICENSE']) self.assertEqual('', result)
def test_diff__non_git_path(): path = os.path.abspath(clone_path + '/../../../') git.diff(path)