diff --git a/pre_commit/commands/run.py b/pre_commit/commands/run.py index 9cd3dfcf..713603b3 100644 --- a/pre_commit/commands/run.py +++ b/pre_commit/commands/run.py @@ -257,17 +257,20 @@ def run(config_file, store, args, environ=os.environ): for repo in repositories(config, store): for _, hook in repo.hooks: if ( - (not args.hook or hook['id'] == args.hook or ( - hook['alias'] and hook['alias'] == args.hook - )) and - (not hook['stages'] or args.hook_stage in hook['stages']) + ( + not args.hook or + hook['id'] == args.hook or + hook['alias'] == args.hook + ) and + ( + not hook['stages'] or + args.hook_stage in hook['stages'] + ) ): repo_hooks.append((repo, hook)) if args.hook and not repo_hooks: - output.write_line( - 'No hook with id or alias `{}`'.format(args.hook), - ) + output.write_line('No hook with id `{}`'.format(args.hook)) return 1 for repo in {repo for repo, _ in repo_hooks}: diff --git a/tests/repository_test.py b/tests/repository_test.py index f1b0f6e0..4d851f59 100644 --- a/tests/repository_test.py +++ b/tests/repository_test.py @@ -831,6 +831,7 @@ def test_manifest_hooks(tempdir_factory, store): 'exclude': '^$', 'files': '', 'id': 'bash_hook', + 'alias': '', 'language': 'script', 'language_version': 'default', 'log_file': '',