Skip to content

Bug: base manifest value for 'exclude' is always ignored #227

Closed

Description

@Lucas-C

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

  1. asottile commented on May 10, 2015

    @asottile
    Member

    Ah the fix in #185 makes more sense now! I just didn't connect 2 and 2 together.

  2. added 2 commits that reference this issue on May 18, 2015
    843155a
    b140f92
  3. Lucas-C commented on May 18, 2015

    @Lucas-C
    ContributorAuthor

    I added a few comments but it looks good, thanks !

  4. added a commit that references this issue on May 18, 2015
    039a7a5
  5. added a commit that references this issue on May 18, 2015
    483c4a3
  6. added a commit that references this issue on Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions