コード例 #1
0
ファイル: git_test.py プロジェクト: MMontgomeryII/pre-commit
def test_get_conflicted_files(in_merge_conflict):
    resolve_conflict()
    with open('other_file', 'w') as other_file:
        other_file.write('oh hai')
    cmd_output('git', 'add', 'other_file')

    ret = set(git.get_conflicted_files())
    assert ret == set(('conflict_file', 'other_file'))
コード例 #2
0
def test_get_conflicted_files(in_merge_conflict):
    resolve_conflict()
    with open('other_file', 'w') as other_file:
        other_file.write('oh hai')
    cmd_output('git', 'add', 'other_file')

    ret = set(git.get_conflicted_files())
    assert ret == {'conflict_file', 'other_file'}
コード例 #3
0
ファイル: git_test.py プロジェクト: imbstack/pre-commit
def test_get_conflicted_files(in_merge_conflict):
    resolve_conflict()
    with open("other_file", "w") as other_file:
        other_file.write("oh hai")
    cmd_output("git", "add", "other_file")

    ret = set(git.get_conflicted_files())
    assert ret == set(("conflict_file", "other_file"))
コード例 #4
0
def test_get_conflicted_files_unstaged_files(in_merge_conflict):
    """This case no longer occurs, but it is a useful test nonetheless"""
    resolve_conflict()

    # Make unstaged file.
    with open('bar_only_file', 'w') as bar_only_file:
        bar_only_file.write('new contents!\n')

    ret = set(git.get_conflicted_files())
    assert ret == {'conflict_file'}
コード例 #5
0
ファイル: git_test.py プロジェクト: pre-commit/pre-commit
def test_get_conflicted_files_unstaged_files(in_merge_conflict):
    """This case no longer occurs, but it is a useful test nonetheless"""
    resolve_conflict()

    # Make unstaged file.
    with open('bar_only_file', 'w') as bar_only_file:
        bar_only_file.write('new contents!\n')

    ret = set(git.get_conflicted_files())
    assert ret == {'conflict_file'}
コード例 #6
0
ファイル: git_test.py プロジェクト: jebcat1982/pre-commit
def test_get_conflicted_files_unstaged_files(in_merge_conflict):
    # If they for whatever reason did pre-commit run --no-stash during a
    # conflict
    resolve_conflict()

    # Make unstaged file.
    with open('bar_only_file', 'w') as bar_only_file:
        bar_only_file.write('new contents!\n')

    ret = set(git.get_conflicted_files())
    assert ret == {'conflict_file'}
コード例 #7
0
ファイル: git_test.py プロジェクト: imbstack/pre-commit
def test_get_conflicted_files_unstaged_files(in_merge_conflict):
    # If they for whatever reason did pre-commit run --no-stash during a
    # conflict
    resolve_conflict()

    # Make unstaged file.
    with open("bar_only_file", "w") as bar_only_file:
        bar_only_file.write("new contents!\n")

    ret = set(git.get_conflicted_files())
    assert ret == set(("conflict_file",))
コード例 #8
0
def _all_filenames(args: argparse.Namespace) -> Collection[str]:
    if args.origin and args.source:
        return git.get_changed_files(args.origin, args.source)
    elif args.hook_stage in {'prepare-commit-msg', 'commit-msg'}:
        return (args.commit_msg_filename, )
    elif args.files:
        return args.files
    elif args.all_files:
        return git.get_all_files()
    elif git.is_in_merge_conflict():
        return git.get_conflicted_files()
    else:
        return git.get_staged_files()
コード例 #9
0
ファイル: run.py プロジェクト: tpriyanshu90/motiBot
def _all_filenames(args):
    if args.origin and args.source:
        return git.get_changed_files(args.origin, args.source)
    elif args.hook_stage == 'commit-msg':
        return (args.commit_msg_filename, )
    elif args.files:
        return args.files
    elif args.all_files:
        return git.get_all_files()
    elif git.is_in_merge_conflict():
        return git.get_conflicted_files()
    else:
        return git.get_staged_files()
コード例 #10
0
ファイル: run.py プロジェクト: pre-commit/pre-commit
def _all_filenames(args):
    if args.origin and args.source:
        return git.get_changed_files(args.origin, args.source)
    elif args.hook_stage in {'prepare-commit-msg', 'commit-msg'}:
        return (args.commit_msg_filename,)
    elif args.files:
        return args.files
    elif args.all_files:
        return git.get_all_files()
    elif git.is_in_merge_conflict():
        return git.get_conflicted_files()
    else:
        return git.get_staged_files()
コード例 #11
0
ファイル: run.py プロジェクト: ejazs/showcase
def _all_filenames(args: argparse.Namespace) -> Collection[str]:
    if args.hook_stage == 'post-checkout':  # no files for post-checkout
        return ()
    elif args.hook_stage in {'prepare-commit-msg', 'commit-msg'}:
        return (args.commit_msg_filename, )
    elif args.from_ref and args.to_ref:
        return git.get_changed_files(args.from_ref, args.to_ref)
    elif args.files:
        return args.files
    elif args.all_files:
        return git.get_all_files()
    elif git.is_in_merge_conflict():
        return git.get_conflicted_files()
    else:
        return git.get_staged_files()
コード例 #12
0
def _all_filenames(args: argparse.Namespace) -> Collection[str]:
    # these hooks do not operate on files
    if args.hook_stage in {"post-checkout", "post-commit"}:
        return ()
    elif args.hook_stage in {"prepare-commit-msg", "commit-msg"}:
        return (args.commit_msg_filename,)
    elif args.from_ref and args.to_ref:
        return git.get_changed_files(args.from_ref, args.to_ref)
    elif args.files:
        return args.files
    elif args.all_files:
        return git.get_all_files()
    elif git.is_in_merge_conflict():
        return git.get_conflicted_files()
    else:
        return git.get_staged_files()
コード例 #13
0
def test_get_conflicted_files_non_ascii(in_merge_conflict):
    open('интервью', 'a').close()
    cmd_output('git', 'add', '.')
    ret = git.get_conflicted_files()
    assert ret == {'conflict_file', 'интервью'}
コード例 #14
0
def test_get_conflicted_files_in_submodule(in_conflicting_submodule):
    resolve_conflict()
    assert set(git.get_conflicted_files()) == {'conflict_file'}
コード例 #15
0
ファイル: git_test.py プロジェクト: akramhussein/pre-commit
def test_get_conflicted_files_in_submodule(in_conflicting_submodule):
    resolve_conflict()
    assert set(git.get_conflicted_files()) == set(('conflict_file',))
コード例 #16
0
ファイル: git_test.py プロジェクト: pre-commit/pre-commit
def test_get_conflicted_files_non_ascii(in_merge_conflict):
    open('интервью', 'a').close()
    cmd_output('git', 'add', '.')
    ret = git.get_conflicted_files()
    assert ret == {'conflict_file', 'интервью'}