add pre-commit hazmat

This commit is contained in:
anthony sottile 2025-11-21 16:38:55 -05:00
parent 9c7ea88ab9
commit bdf68790b7
7 changed files with 243 additions and 2 deletions

View file

@ -164,3 +164,15 @@ def test_basic_run_hook(tmp_path):
assert ret == 0
out = out.replace(b'\r\n', b'\n')
assert out == b'hi hello file file file\n'
def test_hook_cmd():
assert lang_base.hook_cmd('echo hi', ()) == ('echo', 'hi')
def test_hook_cmd_hazmat():
ret = lang_base.hook_cmd('pre-commit hazmat cd a echo -- b', ())
assert ret == (
sys.executable, '-m', 'pre_commit.commands.hazmat',
'cd', 'a', 'echo', '--', 'b',
)