mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Output a message when a hook fails due to file modification
This commit is contained in:
parent
c6200329a2
commit
91a547ed61
4 changed files with 36 additions and 7 deletions
|
|
@ -40,9 +40,9 @@ def repo_with_failing_hook(tempdir_factory):
|
|||
yield git_path
|
||||
|
||||
|
||||
def stage_a_file():
|
||||
cmd_output('touch', 'foo.py')
|
||||
cmd_output('git', 'add', 'foo.py')
|
||||
def stage_a_file(filename='foo.py'):
|
||||
cmd_output('touch', filename)
|
||||
cmd_output('git', 'add', filename)
|
||||
|
||||
|
||||
def get_write_mock_output(write_mock):
|
||||
|
|
@ -127,16 +127,22 @@ def test_hook_that_modifies_but_returns_zero(
|
|||
tempdir_factory, 'modified_file_returns_zero_repo',
|
||||
)
|
||||
with cwd(git_path):
|
||||
stage_a_file('bar.py')
|
||||
_test_run(
|
||||
git_path,
|
||||
{},
|
||||
(
|
||||
# The first should fail
|
||||
b'Failed',
|
||||
# With a modified file (the hook's output)
|
||||
# With a modified file (default message + the hook's output)
|
||||
b'Files were modified by this hook. Additional output:\n\n'
|
||||
b'Modified: foo.py',
|
||||
# The next hook should pass despite the first modifying
|
||||
b'Passed',
|
||||
# The next hook should fail
|
||||
b'Failed',
|
||||
# bar.py was modified, but provides no additional output
|
||||
b'Files were modified by this hook.\n',
|
||||
),
|
||||
1,
|
||||
True,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue