You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: base manifest value for 'exclude' is always ignored #227
I stumbled upon this bug while working on #226: the culprit is Repository.hooks.
A quick fix for this would be to simply remove the default value from pre_commit/clientlib/validate_config.py, but the root cause is that any default value defined for a field in this file will make the corresponding manifest field useless.
Basically here is what happens in Repository.hooks:
all the hooks defined in the current repository are enumerated
at this stage, a hook is a dict closely matching the Yaml the config file content, plus default values for fields not defined in the Yaml but having a JSON schema 'default'
when doing the dict merge, every (key,value) pair in hook overrides the corresponding manifest entry. This includes default config value like exclude: '$^' overriding a base manifest value like exclude: '.bak$'
Hence I suggest either adding a test ensuring there will never be any 'default' defined in CONFIG_JSON_SCHEMA, or improving the merge logic.
Activity
asottile commentedon May 10, 2015
Ah the fix in #185 makes more sense now! I just didn't connect 2 and 2 together.
Remove defaults from pre-commit config schema. Resolves #227
Remove defaults from pre-commit config schema. Resolves #227
Lucas-C commentedon May 18, 2015
I added a few comments but it looks good, thanks !
Remove defaults from pre-commit config schema. Resolves #227
Merge pull request #231 from pre-commit/no_defaults_in_config_227
Merge pull request pre-commit#227 from pre-commit/better_tests_regex