Implement check-useless-excludes meta hook · precommit/pre-commit@8df11ee · GitHub
Skip to content

Commit 8df11ee

Browse files
committed
Implement check-useless-excludes meta hook
1 parent 88c676a commit 8df11ee

4 files changed

Lines changed: 118 additions & 8 deletions

File tree

pre_commit/meta_hooks/__init__.py

Whitespace-only changes.
Lines changed: 41 additions & 0 deletions

pre_commit/repository.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import json
55
import logging
66
import os
7+
import pipes
78
import shutil
89
import sys
910
from collections import defaultdict
@@ -247,13 +248,16 @@ def _venvs(self):
247248

248249

249250
class MetaRepository(LocalRepository):
251+
# Note: the hook `entry` is passed through `shlex.split()` by the command
252+
# runner, so to prevent issues with spaces and backslashes (on Windows) it
253+
# must be quoted here.
250254
meta_hooks = {
251-
'test-hook': {
252-
'name': 'Test Hook',
253-
'files': '',
255+
'check-useless-excludes': {
256+
'name': 'Check for useless excludes',
257+
'files': '.pre-commit-config.yaml',
254258
'language': 'system',
255-
'entry': 'echo "Hello World!"',
256-
'always_run': True,
259+
'entry': pipes.quote(sys.executable),
260+
'args': ['-m', 'pre_commit.meta_hooks.check_useless_excludes'],
257261
},
258262
}
259263

tests/commands/run_test.py

Lines changed: 68 additions & 3 deletions

0 commit comments

Comments
 (0)