mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Adding support for locally-defined hooks
This commit is contained in:
parent
d97ea30c4b
commit
b68261c720
8 changed files with 241 additions and 40 deletions
|
|
@ -6,6 +6,13 @@ from pre_commit.clientlib.validate_base import is_regex_valid
|
|||
from pre_commit.errors import FatalError
|
||||
|
||||
|
||||
_LOCAL_HOOKS_MAGIC_REPO_STRING = 'local'
|
||||
|
||||
|
||||
def is_local_hooks(repo_entry):
|
||||
return repo_entry['repo'] == _LOCAL_HOOKS_MAGIC_REPO_STRING
|
||||
|
||||
|
||||
class InvalidConfigError(FatalError):
|
||||
pass
|
||||
|
||||
|
|
@ -53,7 +60,12 @@ def try_regex(repo, hook, value, field_name):
|
|||
|
||||
def validate_config_extra(config):
|
||||
for repo in config:
|
||||
if 'sha' not in repo:
|
||||
if is_local_hooks(repo):
|
||||
if 'sha' in repo:
|
||||
raise InvalidConfigError(
|
||||
'"sha" property provided for local hooks'
|
||||
)
|
||||
elif 'sha' not in repo:
|
||||
raise InvalidConfigError(
|
||||
'Missing "sha" field for repository {0}'.format(repo['repo'])
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue