mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Fail a hook if it makes modifications. Resolves #285
This commit is contained in:
parent
67f6f812c4
commit
a3f78bc165
5 changed files with 47 additions and 0 deletions
|
|
@ -120,6 +120,29 @@ def test_arbitrary_bytes_hook(tempdir_factory, mock_out_store_directory):
|
|||
_test_run(git_path, {}, (b'\xe2\x98\x83\xb2\n',), 1, True)
|
||||
|
||||
|
||||
def test_hook_that_modifies_but_returns_zero(
|
||||
tempdir_factory, mock_out_store_directory,
|
||||
):
|
||||
git_path = make_consuming_repo(
|
||||
tempdir_factory, 'modified_file_returns_zero_repo',
|
||||
)
|
||||
with cwd(git_path):
|
||||
_test_run(
|
||||
git_path,
|
||||
{},
|
||||
(
|
||||
# The first should fail
|
||||
b'Failed',
|
||||
# With a modified file (the hook's output)
|
||||
b'Modified: foo.py',
|
||||
# The next hook should pass despite the first modifying
|
||||
b'Passed',
|
||||
),
|
||||
1,
|
||||
True,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
('options', 'outputs', 'expected_ret', 'stage'),
|
||||
(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue