Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2eacc06

Browse files
committed
--hook-type is required for hook-impl
1 parent f5678bf commit 2eacc06

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

pre_commit/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def _add_cmd(name: str, *, help: str) -> argparse.ArgumentParser:
357357
hook_impl_parser = subparsers.add_parser('hook-impl')
358358
add_color_option(hook_impl_parser)
359359
_add_config_option(hook_impl_parser)
360-
hook_impl_parser.add_argument('--hook-type')
360+
hook_impl_parser.add_argument('--hook-type', required=True)
361361
hook_impl_parser.add_argument('--hook-dir')
362362
hook_impl_parser.add_argument(
363363
'--skip-on-missing-config', action='store_true',

tests/main_test.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_adjust_args_try_repo_repo_relative(in_git_dir):
9090

9191

9292
FNS = (
93-
'autoupdate', 'clean', 'gc', 'hook_impl', 'install', 'install_hooks',
93+
'autoupdate', 'clean', 'gc', 'install', 'install_hooks',
9494
'migrate_config', 'run', 'sample_config', 'uninstall',
9595
'validate_config', 'validate_manifest',
9696
)
@@ -169,6 +169,12 @@ def test_hazmat(mock_store_dir):
169169
assert arg.cmd == ['cmd', '--', 'f1', 'f2']
170170

171171

172+
def test_hook_impl(mock_store_dir):
173+
with mock.patch.object(main, 'hook_impl') as mck:
174+
main.main(('hook-impl', '--hook-type', 'pre-commit'))
175+
assert mck.call_count == 1
176+
177+
172178
def test_try_repo(mock_store_dir):
173179
with mock.patch.object(main, 'try_repo') as patch:
174180
main.main(('try-repo', '.'))

0 commit comments

Comments
 (0)