mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Merge pull request #653 from pre-commit/rename_meta_hook
Rename check-files-matches-any to check-hooks-apply
This commit is contained in:
commit
6a177c41ca
4 changed files with 11 additions and 11 deletions
|
|
@ -27,5 +27,5 @@ repos:
|
||||||
- id: add-trailing-comma
|
- id: add-trailing-comma
|
||||||
- repo: meta
|
- repo: meta
|
||||||
hooks:
|
hooks:
|
||||||
|
- id: check-hooks-apply
|
||||||
- id: check-useless-excludes
|
- id: check-useless-excludes
|
||||||
- id: check-files-matches-any
|
|
||||||
|
|
|
||||||
|
|
@ -255,7 +255,7 @@ class MetaRepository(LocalRepository):
|
||||||
@cached_property
|
@cached_property
|
||||||
def manifest_hooks(self):
|
def manifest_hooks(self):
|
||||||
# The hooks are imported here to prevent circular imports.
|
# The hooks are imported here to prevent circular imports.
|
||||||
from pre_commit.meta_hooks import check_files_matches_any
|
from pre_commit.meta_hooks import check_hooks_apply
|
||||||
from pre_commit.meta_hooks import check_useless_excludes
|
from pre_commit.meta_hooks import check_useless_excludes
|
||||||
|
|
||||||
def _make_entry(mod):
|
def _make_entry(mod):
|
||||||
|
|
@ -267,11 +267,11 @@ class MetaRepository(LocalRepository):
|
||||||
|
|
||||||
meta_hooks = [
|
meta_hooks = [
|
||||||
{
|
{
|
||||||
'id': 'check-files-matches-any',
|
'id': 'check-hooks-apply',
|
||||||
'name': 'Check hooks match any files',
|
'name': 'Check hooks apply to the repository',
|
||||||
'files': '.pre-commit-config.yaml',
|
'files': '.pre-commit-config.yaml',
|
||||||
'language': 'system',
|
'language': 'system',
|
||||||
'entry': _make_entry(check_files_matches_any),
|
'entry': _make_entry(check_hooks_apply),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'id': 'check-useless-excludes',
|
'id': 'check-useless-excludes',
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from pre_commit.meta_hooks import check_files_matches_any
|
from pre_commit.meta_hooks import check_hooks_apply
|
||||||
from pre_commit.util import cwd
|
from pre_commit.util import cwd
|
||||||
from testing.fixtures import add_config_to_repo
|
from testing.fixtures import add_config_to_repo
|
||||||
from testing.fixtures import git_dir
|
from testing.fixtures import git_dir
|
||||||
|
|
@ -25,7 +25,7 @@ def test_hook_excludes_everything(
|
||||||
add_config_to_repo(repo, config)
|
add_config_to_repo(repo, config)
|
||||||
|
|
||||||
with cwd(repo):
|
with cwd(repo):
|
||||||
assert check_files_matches_any.main(()) == 1
|
assert check_hooks_apply.main(()) == 1
|
||||||
|
|
||||||
out, _ = capsys.readouterr()
|
out, _ = capsys.readouterr()
|
||||||
assert 'check-useless-excludes does not apply to this repository' in out
|
assert 'check-useless-excludes does not apply to this repository' in out
|
||||||
|
|
@ -50,7 +50,7 @@ def test_hook_includes_nothing(
|
||||||
add_config_to_repo(repo, config)
|
add_config_to_repo(repo, config)
|
||||||
|
|
||||||
with cwd(repo):
|
with cwd(repo):
|
||||||
assert check_files_matches_any.main(()) == 1
|
assert check_hooks_apply.main(()) == 1
|
||||||
|
|
||||||
out, _ = capsys.readouterr()
|
out, _ = capsys.readouterr()
|
||||||
assert 'check-useless-excludes does not apply to this repository' in out
|
assert 'check-useless-excludes does not apply to this repository' in out
|
||||||
|
|
@ -75,7 +75,7 @@ def test_hook_types_not_matched(
|
||||||
add_config_to_repo(repo, config)
|
add_config_to_repo(repo, config)
|
||||||
|
|
||||||
with cwd(repo):
|
with cwd(repo):
|
||||||
assert check_files_matches_any.main(()) == 1
|
assert check_hooks_apply.main(()) == 1
|
||||||
|
|
||||||
out, _ = capsys.readouterr()
|
out, _ = capsys.readouterr()
|
||||||
assert 'check-useless-excludes does not apply to this repository' in out
|
assert 'check-useless-excludes does not apply to this repository' in out
|
||||||
|
|
@ -100,7 +100,7 @@ def test_hook_types_excludes_everything(
|
||||||
add_config_to_repo(repo, config)
|
add_config_to_repo(repo, config)
|
||||||
|
|
||||||
with cwd(repo):
|
with cwd(repo):
|
||||||
assert check_files_matches_any.main(()) == 1
|
assert check_hooks_apply.main(()) == 1
|
||||||
|
|
||||||
out, _ = capsys.readouterr()
|
out, _ = capsys.readouterr()
|
||||||
assert 'check-useless-excludes does not apply to this repository' in out
|
assert 'check-useless-excludes does not apply to this repository' in out
|
||||||
|
|
@ -124,7 +124,7 @@ def test_valid_includes(
|
||||||
add_config_to_repo(repo, config)
|
add_config_to_repo(repo, config)
|
||||||
|
|
||||||
with cwd(repo):
|
with cwd(repo):
|
||||||
assert check_files_matches_any.main(()) == 0
|
assert check_hooks_apply.main(()) == 0
|
||||||
|
|
||||||
out, _ = capsys.readouterr()
|
out, _ = capsys.readouterr()
|
||||||
assert out == ''
|
assert out == ''
|
||||||
Loading…
Add table
Add a link
Reference in a new issue