Skip to content

Commit a70abd0

Browse files
author
Benjamin Chess
committed
include checking symlinks
1 parent b00637b commit a70abd0

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

pre_commit/git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def wrapper(include_expr, exclude_expr):
8989
if (
9090
include_regex.search(filename) and
9191
not exclude_regex.search(filename) and
92-
os.path.exists(filename)
92+
os.path.lexists(filename)
9393
)
9494
)
9595
return wrapper

testing/test_symlink

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
does_not_exist

tests/git_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def get_filenames():
6161
'pre_commit/main.py',
6262
'pre_commit/git.py',
6363
'im_a_file_that_doesnt_exist.py',
64+
'testing/test_symlink',
6465
'hooks.yaml',
6566
)
6667

@@ -73,6 +74,7 @@ def test_get_files_matching_base(get_files_matching_func):
7374
'pre_commit/main.py',
7475
'pre_commit/git.py',
7576
'hooks.yaml',
77+
'testing/test_symlink'
7678
])
7779

7880

@@ -96,7 +98,7 @@ def test_does_not_include_deleted_fileS(get_files_matching_func):
9698

9799
def test_exclude_removes_files(get_files_matching_func):
98100
ret = get_files_matching_func('', '\\.py$')
99-
assert ret == set(['hooks.yaml'])
101+
assert ret == set(['hooks.yaml', 'testing/test_symlink'])
100102

101103

102104
def resolve_conflict():

0 commit comments

Comments
 (0)