mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Fix patch applying when apply.whitespace=error
This commit is contained in:
parent
ec102a842a
commit
d5e2af7de5
2 changed files with 14 additions and 3 deletions
|
|
@ -45,7 +45,10 @@ def staged_files_only(cmd_runner):
|
|||
finally:
|
||||
# Try to apply the patch we saved
|
||||
try:
|
||||
cmd_runner.run(('git', 'apply', patch_filename), encoding=None)
|
||||
cmd_runner.run(
|
||||
('git', 'apply', '--whitespace=nowarn', patch_filename),
|
||||
encoding=None,
|
||||
)
|
||||
except CalledProcessError:
|
||||
logger.warning(
|
||||
'Stashed changes conflicted with hook auto-fixes... '
|
||||
|
|
@ -55,7 +58,10 @@ def staged_files_only(cmd_runner):
|
|||
# by hooks.
|
||||
# Roll back the changes made by hooks.
|
||||
cmd_runner.run(['git', 'checkout', '--', '.'])
|
||||
cmd_runner.run(('git', 'apply', patch_filename), encoding=None)
|
||||
cmd_runner.run(
|
||||
('git', 'apply', patch_filename, '--whitespace=nowarn'),
|
||||
encoding=None,
|
||||
)
|
||||
logger.info('Restored changes from {}.'.format(patch_filename))
|
||||
else:
|
||||
# There weren't any staged files so we don't need to do anything
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue