--hook-type is required for hook-impl

This commit is contained in:
anthony sottile
2026-04-21 15:16:40 -04:00
parent f5678bf4ac
commit 2eacc064aa
2 changed files with 8 additions and 2 deletions
+1 -1
View File
@@ -357,7 +357,7 @@ def main(argv: Sequence[str] | None = None) -> int:
hook_impl_parser = subparsers.add_parser('hook-impl')
add_color_option(hook_impl_parser)
_add_config_option(hook_impl_parser)
hook_impl_parser.add_argument('--hook-type')
hook_impl_parser.add_argument('--hook-type', required=True)
hook_impl_parser.add_argument('--hook-dir')
hook_impl_parser.add_argument(
'--skip-on-missing-config', action='store_true',
+7 -1
View File
@@ -90,7 +90,7 @@ def test_adjust_args_try_repo_repo_relative(in_git_dir):
FNS = (
'autoupdate', 'clean', 'gc', 'hook_impl', 'install', 'install_hooks',
'autoupdate', 'clean', 'gc', 'install', 'install_hooks',
'migrate_config', 'run', 'sample_config', 'uninstall',
'validate_config', 'validate_manifest',
)
@@ -169,6 +169,12 @@ def test_hazmat(mock_store_dir):
assert arg.cmd == ['cmd', '--', 'f1', 'f2']
def test_hook_impl(mock_store_dir):
with mock.patch.object(main, 'hook_impl') as mck:
main.main(('hook-impl', '--hook-type', 'pre-commit'))
assert mck.call_count == 1
def test_try_repo(mock_store_dir):
with mock.patch.object(main, 'try_repo') as patch:
main.main(('try-repo', '.'))