mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 16:24:40 +04:00
Don't pass deleted files to pre-commit scripts.
This commit is contained in:
parent
6649e180bb
commit
bef4a01af9
2 changed files with 15 additions and 12 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import functools
|
||||
import os
|
||||
import os.path
|
||||
import pkg_resources
|
||||
import re
|
||||
from plumbum import local
|
||||
|
|
@ -57,14 +58,13 @@ def get_files_matching(all_file_list_strategy):
|
|||
@memoize_by_cwd
|
||||
def wrapper(expr):
|
||||
regex = re.compile(expr)
|
||||
return set(
|
||||
return set(filter(os.path.exists, (
|
||||
filename
|
||||
for filename in all_file_list_strategy()
|
||||
if regex.search(filename)
|
||||
)
|
||||
)))
|
||||
return wrapper
|
||||
|
||||
|
||||
|
||||
get_staged_files_matching = get_files_matching(get_staged_files)
|
||||
get_all_files_matching = get_files_matching(get_all_files)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue