Add --hook-args option to try-repo

This commit is contained in:
George Ogden 2025-10-06 18:19:04 +02:00
parent 99fa9ba5ef
commit 6d22fc01d0
No known key found for this signature in database
GPG key ID: 7535155E9AA29EDB
3 changed files with 53 additions and 3 deletions

View file

@ -4,6 +4,7 @@ import argparse
import logging
import os.path
import tempfile
import warnings
import pre_commit.constants as C
from pre_commit import git
@ -54,8 +55,15 @@ def try_repo(args: argparse.Namespace) -> int:
store = Store(tempdir)
if args.hook:
hooks = [{'id': args.hook}]
hook = {'id': args.hook}
if args.hook_args is not None:
hook['args'] = args.hook_args
hooks = [hook]
else:
if args.hook_args is not None:
warnings.warn(
"Unused flag '--hook-args' as 'hook' is not specified.",
)
repo_path = store.clone(repo, ref)
manifest = load_manifest(os.path.join(repo_path, C.MANIFEST_FILE))
manifest = sorted(manifest, key=lambda hook: hook['id'])