Use pre-commit to automate installation and management of all pre-commit hooks
elpaso opened this issue · comments
QGIS Enhancement: Use pre-commit to automate the installation and management of all pre-commit hooks
Date 2023/04/05
Author Alessandro Pasotti (@elpaso)
Contact elpaso at itopen dot it
maintainer @elpaso
Version QGIS 3.34
Summary
QGIS is currently using a set of pre-commit hooks to run scripts that manage the source code (format, checks etc.) before each commit.
Hooks must be installed manually which is not ideal.
Proposed Solution
Switch to https://pre-commit.com/ to manage our pre-commit hooks, this framework provides automated installation and configuration of the hooks, it has also a set of pre-defined hooks ready to use https://pre-commit.com/hooks.html
To install the hooks a user will just run pre-commit install to install pre-commit into the git hooks. pre-commit will now run on every commit. Every time you clone a project using pre-commit running pre-commit install should always be the first thing you do.
GDAL is successfully using this system.
Affected Files
Current pre-hook scripts.
Performance Implications
None
Backwards Compatibility
None
Votes
(required)
Good idea, I though it's was already used!
And use pre-commit.ci to run hooks on PR?
And use pre-commit.ci to run hooks on PR?
Definitely: I'd need to check if that works with our hooks but it looks promising!
We've had very good experiences with pre-commit (still happily using https://github.com/pre-commit/action)