Add pass_filenames hook option

This option controls whether filenames are passed along as arguments to
the hook program.
This commit is contained in:
André Berti Sassi 2017-05-12 23:24:04 -03:00
parent 6025475afb
commit e774c09fac
4 changed files with 33 additions and 1 deletions

View file

@ -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