Package: centralized-pre-commit-conf
Centralizedpre-commitconfigurationEasily install and update centralized pre-commit hooks and their configuration files in
decentralized repositories.To be able to validate and automatically fix commits we're usinggit hooks.We're also heavily relying onpre-commit, which is a framework for managing and
maintaining multi-language pre-commit hooks. Please refer to thepre-commit documentation here.PhilosophyIn order to be able to install all the tools and linters in a single command with up to
date centralized configurations, we're copying the configurations files of your tools
(.pre-commit-config.yaml,isort.cfg,.flake8,.clang-format, ...) from an URL to
your local git directory and we then installpre-commit.Why not use onlypre-commitby @asotile? Well,in his words:pre-commit will not directly support mutability in configuration (this includes
referencing a centralized repository). This causes lots of issues with repeatability
and maintenance in general. This was an early design decision after seeing the pain
caused at scale when a linter changes behaviour and suddenly every repository's master
branch is broken.So if you disagree and want decentralized repository with centralized lint
configuration, you need a tool on top of pre-commit to shoot yourself in the foot
anyway. Or more realistically to update your configuration files from a central
repository from time to time.More seriously, the alternative is to useall-reposto mass update a bunch of
decentralized repositories with a decentralized configuration.Installationpip3installcentralized-pre-commit-confUsageSeepre-commit-conf --helpfor options.Installing hooksFor example with thisconfig.yamlinone of the appropriate search paths:configuration_files:-".pylintrc"-".pre-commit-config.yaml"repository:https://mycompany.net/lint-conf/branch:masterupdate_gitignore:Truepath:"pre-commit/static/"gitignore_info_text:"#Configurationfileaddedautomaticallyby'centralized-pre-commit-conf'"pre-commit-confwould recover the defined configuration files fromhttps://mycompany.net/lint-conf/master/pre-commit/static/and update the.gitignore:Youcansettheoptionsystemwidein/home/pierre/.config/pre-commit-conf/config.yaml.
✨Successfullyretrieved.pre-commit-config.yaml✨
✨Successfullyretrieved.pylintrc✨
✨Updated.gitignoresuccessfullywith{'.pre-commit-config.yaml','.pylintrc'}.✨🎉2configurationfilesrecoveredandpre-commitinstalledcorrectly.🎉Here would the content of the.gitignore:# Configuration file added automatically by 'centralized-pre-commit-conf'.pre-commit-config.yaml.pylintrcThen with the same configuration, usingpre-commit-conf --branch hardcore-pylint-confwould try to recover the configuration files fromhttps://mycompany.net/lint-conf/hardcore-pylint-conf/pre-commit/static/instead.Youcansettheoptionsystemwidein/home/pierre/.config/pre-commit-conf/config.yaml.
Foundexisting.pre-commit-config.yaml⁉️Use'-f'or'--replace-existing'toforceerase.
Foundexisting.pylintrc⁉️Use'-f'or'--replace-existing'toforceerase.
Allconfigurationfilesalreadyexisted.Next commit supposing the.pre-commit-config.yamlis done correctly your modified
files we be linted with the centralized configuration.Development / contributionpip3install-e".[test]"pre-commit-conf
python3-mpytest--covcentralized_pre_commit_confPull requests are welcome :)