Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion testing/test_symlink

This file was deleted.

13 changes: 10 additions & 3 deletions tests/git_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from pre_commit.util import cmd_output
from pre_commit.util import cwd
from testing.fixtures import git_dir
from testing.util import xfailif_no_symlink


def test_get_root_at_root(tempdir_factory):
Expand Down Expand Up @@ -72,7 +73,6 @@ def get_filenames():
'pre_commit/main.py',
'pre_commit/git.py',
'im_a_file_that_doesnt_exist.py',
'testing/test_symlink',
)

return git.get_files_matching(get_filenames)
Expand All @@ -84,10 +84,17 @@ def test_get_files_matching_base(get_files_matching_func):
'.pre-commit-hooks.yaml',
'pre_commit/main.py',
'pre_commit/git.py',
'testing/test_symlink'
}


@xfailif_no_symlink
def test_matches_broken_symlink(tmpdir): # pragma: no cover (non-windwos)
with tmpdir.as_cwd():
os.symlink('does-not-exist', 'link')
func = git.get_files_matching(lambda: ('link',))
assert func('', '^$') == {'link'}


def test_get_files_matching_total_match(get_files_matching_func):
ret = get_files_matching_func('^.*\\.py$', '^$')
assert ret == {'pre_commit/main.py', 'pre_commit/git.py'}
Expand All @@ -105,7 +112,7 @@ def test_does_not_include_deleted_fileS(get_files_matching_func):

def test_exclude_removes_files(get_files_matching_func):
ret = get_files_matching_func('', '\\.py$')
assert ret == {'.pre-commit-hooks.yaml', 'testing/test_symlink'}
assert ret == {'.pre-commit-hooks.yaml'}


def resolve_conflict():
Expand Down