Esempio n. 1
0
def test_get_changed_files(in_git_dir):
    git_commit()
    in_git_dir.join('a.txt').ensure()
    in_git_dir.join('b.txt').ensure()
    cmd_output('git', 'add', '.')
    git_commit()
    files = git.get_changed_files('HEAD', 'HEAD^')
    assert files == ['a.txt', 'b.txt']

    # files changed in source but not in origin should not be returned
    files = git.get_changed_files('HEAD^', 'HEAD')
    assert files == []
Esempio n. 2
0
def test_get_changed_files(in_git_dir):
    git_commit()
    in_git_dir.join('a.txt').ensure()
    in_git_dir.join('b.txt').ensure()
    cmd_output('git', 'add', '.')
    git_commit()
    files = git.get_changed_files('HEAD^', 'HEAD')
    assert files == ['a.txt', 'b.txt']

    # files changed in source but not in origin should not be returned
    files = git.get_changed_files('HEAD', 'HEAD^')
    assert files == []
Esempio n. 3
0
def test_get_changed_files(in_tmpdir):
    cmd_output('git', 'init', '.')
    cmd_output('git', 'commit', '--allow-empty', '-m', 'initial commit')
    open('a.txt', 'a').close()
    open('b.txt', 'a').close()
    cmd_output('git', 'add', '.')
    cmd_output('git', 'commit', '-m', 'add some files')
    files = git.get_changed_files('HEAD', 'HEAD^')
    assert files == ['a.txt', 'b.txt']

    # files changed in source but not in origin should not be returned
    files = git.get_changed_files('HEAD^', 'HEAD')
    assert files == []
Esempio n. 4
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()
Esempio n. 5
0
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()
Esempio n. 6
0
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()
Esempio n. 7
0
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()
Esempio n. 8
0
def test_get_changed_files_disparate_histories(in_git_dir):
    """in modern versions of git, `...` does not fall back to full diff"""
    git_commit()
    in_git_dir.join('a.txt').ensure()
    cmd_output('git', 'add', '.')
    git_commit()
    cmd_output('git', 'branch', '-m', 'branch1')

    cmd_output('git', 'checkout', '--orphan', 'branch2')
    cmd_output('git', 'rm', '-rf', '.')
    in_git_dir.join('a.txt').ensure()
    in_git_dir.join('b.txt').ensure()
    cmd_output('git', 'add', '.')
    git_commit()

    assert git.get_changed_files('branch1', 'branch2') == ['b.txt']
Esempio n. 9
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()
Esempio n. 10
0
def test_changed_files_non_ascii(non_ascii_repo):
    ret = git.get_changed_files('HEAD^', 'HEAD')
    assert ret == ['интервью']
Esempio n. 11
0
def test_changed_files_non_ascii(non_ascii_repo):
    ret = git.get_changed_files('HEAD', 'HEAD^')
    assert ret == ['интервью']