mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-14 13:00:10 -06:00
Add pass_filenames hook option
This option controls whether filenames are passed along as arguments to the hook program.
This commit is contained in:
@@ -46,6 +46,7 @@ MANIFEST_HOOK_DICT = schema.Map(
|
||||
),
|
||||
schema.Optional('args', schema.check_array(schema.check_string), []),
|
||||
schema.Optional('always_run', schema.check_bool, False),
|
||||
schema.Optional('pass_filenames', schema.check_bool, True),
|
||||
schema.Optional('description', schema.check_string, ''),
|
||||
schema.Optional(
|
||||
'exclude',
|
||||
|
||||
@@ -86,7 +86,10 @@ def _run_single_hook(hook, repo, args, skips, cols):
|
||||
sys.stdout.flush()
|
||||
|
||||
diff_before = cmd_output('git', 'diff', retcode=None, encoding=None)
|
||||
retcode, stdout, stderr = repo.run_hook(hook, tuple(filenames))
|
||||
retcode, stdout, stderr = repo.run_hook(
|
||||
hook,
|
||||
tuple(filenames) if hook['pass_filenames'] else (),
|
||||
)
|
||||
diff_after = cmd_output('git', 'diff', retcode=None, encoding=None)
|
||||
|
||||
file_modifications = diff_before != diff_after
|
||||
|
||||
Reference in New Issue
Block a user