Beispiel #1
0
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, '')
Beispiel #2
0
    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, '')
Beispiel #3
0
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)
Beispiel #4
0
    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)
Beispiel #5
0
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')
Beispiel #6
0
    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')
Beispiel #7
0
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 []
Beispiel #8
0
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 []
Beispiel #9
0
def test_apply_cached__empty():
    git.apply_cached(clone_path, '')

    # No changes, no diff.
    diff = git.diff(clone_path)
    eq_(diff, '')
Beispiel #10
0
def test_diff__non_git_path():
    git.diff(settings['WORKSPACE'] + '/../../')
Beispiel #11
0
    def test_apply_cached__empty(self):
        git.apply_cached(clone_path, '')

        # No changes, no diff.
        diff = git.diff(clone_path)
        self.assertEqual(diff, '')
Beispiel #12
0
 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)
Beispiel #13
0
def test_diff__non_git_path():
    path = os.path.abspath(clone_path + '/../../../')
    git.diff(path)