Repository navigation
Description
Disclaimer: An idea for a QoL thing I'm not fully convinced about the usefulness of myself.
Intro: We have several dozen repos that all use pre-commit. It can be a pain to manage the .pre-commit-config.yaml files in each of those repositories separately i.e. we may start or stop using some hooks across all repos and then it takes some effort to update all their .pre-commit-config.yaml files. I and others have various scripts and tools built to do mass updates across repositories, but I was thinking about whether there was a simpler way to maintain and think about this.
Idea: Versioned 'suites' or 'collections' of hooks.
Imagine a repo pre_commit_hook_collections containing some directory collections/:
collections/
python_package_hooks.yaml
service_hooks.yaml
frontend_service_hooks.yaml
...
Each of those is a pre-commit config file with the same format as .pre-commit-config.yaml. python_package_hooks.yaml for example might have all the basic hooks we want in every single python package (line ending fixer, pep8, no large files, etc). When we create a new python package we would have it's .pre-commit-config.yaml file look like:
- repo: [email protected]:pre-commit/pre-commit-hook-collections
sha: e9446ff0cc8ffa65309e0a37c247518127a3bf18
collections:
- id: python-package-hooks
language_version: python3.6
pre-commit autoupdate would bump the version of hook collections same as it bumps version of hooks now.
Having a repo's .pre-commit-config.yaml include collection(s) does not mean it can not also specify additional regular precommit hooks. For example, if we add some yaml file to our python package we might specifically add a yaml validator or sorter hook to it.
When we want to add/remove hooks across many repositories it then becomes a job of updating the collections repository with those changes. Then as package authors across the team or multiple teams update their hooks they'll get those changes.
Looking for thoughts on the usefulness of this idea, and feasibility.
Activity
asottile commentedon Jun 27, 2017
I think a lot of this will be addressed with configuration v2: #414
I'm also hesitant:
asottile commentedon Jul 3, 2017
This would also make it impossible to add
exclude/language_version/ etc. (or other configuration) to individual hooks. I don't think this is possible so I'm going to close this. @dlgallagher feel free to reopen if you have additional ideas :)dan98765 commentedon Jul 3, 2017
@asottile thanks for your thoughts on this idea! I'm not familiar with the pre-commit code so I don't have any idea how hard it would be to implement this. If I end up getting inspired sometime down the line to try building this feature I'll try testing it out for awhile to see what all the issues are. Until then it's not that high on my priority list & no need to discuss further here.