Merge pull request #333 from bchess/include_symlinks

include checking symlinks
This commit is contained in:
Anthony Sottile 2016-01-15 13:39:21 -08:00
commit aa6d64beab
3 changed files with 5 additions and 2 deletions

View file

@ -89,7 +89,7 @@ def get_files_matching(all_file_list_strategy):
if ( if (
include_regex.search(filename) and include_regex.search(filename) and
not exclude_regex.search(filename) and not exclude_regex.search(filename) and
os.path.exists(filename) os.path.lexists(filename)
) )
) )
return wrapper return wrapper

1
testing/test_symlink Symbolic link
View file

@ -0,0 +1 @@
does_not_exist

View file

@ -61,6 +61,7 @@ def get_files_matching_func():
'pre_commit/main.py', 'pre_commit/main.py',
'pre_commit/git.py', 'pre_commit/git.py',
'im_a_file_that_doesnt_exist.py', 'im_a_file_that_doesnt_exist.py',
'testing/test_symlink',
'hooks.yaml', 'hooks.yaml',
) )
@ -73,6 +74,7 @@ def test_get_files_matching_base(get_files_matching_func):
'pre_commit/main.py', 'pre_commit/main.py',
'pre_commit/git.py', 'pre_commit/git.py',
'hooks.yaml', 'hooks.yaml',
'testing/test_symlink'
]) ])
@ -96,7 +98,7 @@ def test_does_not_include_deleted_fileS(get_files_matching_func):
def test_exclude_removes_files(get_files_matching_func): def test_exclude_removes_files(get_files_matching_func):
ret = get_files_matching_func('', '\\.py$') ret = get_files_matching_func('', '\\.py$')
assert ret == set(['hooks.yaml']) assert ret == set(['hooks.yaml', 'testing/test_symlink'])
def resolve_conflict(): def resolve_conflict():