Apply defaults to all of the configs. Much fewer .get()s

This commit is contained in:
Anthony Sottile
2014-03-31 23:22:13 -07:00
parent b23ad5d6a3
commit ac67af21ec
13 changed files with 73 additions and 48 deletions

View File

@@ -28,10 +28,10 @@ CONFIG_JSON_SCHEMA = {
'properties': {
'id': {'type': 'string'},
'files': {'type': 'string'},
'exclude': {'type': 'string'},
'exclude': {'type': 'string', 'default': '^$'},
'args': {
'type': 'array',
'minItems': 1,
'default': [],
'items': {'type': 'string'},
},
},
@@ -59,7 +59,7 @@ def validate_config_extra(config):
for repo in config:
for hook in repo['hooks']:
try_regex(repo, hook['id'], hook['files'], 'files')
try_regex(repo, hook['id'], hook.get('exclude', ''), 'exclude')
try_regex(repo, hook['id'], hook['exclude'], 'exclude')
load_config = get_validator(