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 == []
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 == []
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 == []
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()
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()
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()
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()
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']
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()
def test_changed_files_non_ascii(non_ascii_repo): ret = git.get_changed_files('HEAD^', 'HEAD') assert ret == ['интервью']
def test_changed_files_non_ascii(non_ascii_repo): ret = git.get_changed_files('HEAD', 'HEAD^') assert ret == ['интервью']