Skip to content

make files available for use at top-level #1220

Closed

Description

@TheButlah

We have a codebase that we are trying to add pre-commit to, but not everyone on the team wants or trusts the workflow. For this reason, we wanted to make it an opt-in system where by default all directories are excluded from pre-commit, except certain ones.

Ideally, we could accomplish this by being able to use the files: option at the top-level yaml. Because we cannot do this at the top level, we are forced to either add it for every single repo, or invert the value of the regular expression used in the exclude: option at the top-level.

Ergonomically, neither of these choices are good ones - the former requires many repeated files: options and is brittle, and the latter is synactically unintelligible for non-regex experts:

(?x)^(?!( 
    parent\/opt-in-dir1|
    opt-in-dir2
)(\/.*)?$).+

Could you allow us to use files: at the top level?

Activity

  1. asottile commented on Nov 13, 2019

    @asottile
    Member

    sure, would you like to work on a patch for this?

  2. TheButlah commented on Nov 14, 2019

    @TheButlah
    Author

    First, thanks for your rapid response and your project! I can already say after using it for a few days that I really like it. I can try to submit a patch, that being said, it probably won't be something I can get around to just yet since its a hectic time at work rn.

  3. asottile commented on Nov 14, 2019

    @asottile
    Member

    cool, it shouldn't be too difficult -- here's the patch that adds global exclude for instance: https://github.com/pre-commit/pre-commit/pull/617/files

  4. asottile commented on Dec 23, 2019

    @asottile
    Member

    I went ahead and implemented this since it was pretty straightforward -- you should be able to try this out on master (will probably be released some time before I'm back from holiday)

  5. asottile commented on Jan 2, 2020

    @asottile
    Member

    This has been released as part of v1.21.0 -- thanks again for the issue 🎉!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions