ENH: Add pre-commit configuration file to run clang-format#4651
ENH: Add pre-commit configuration file to run clang-format#4651blowekamp wants to merge 3 commits intoInsightSoftwareConsortium:masterfrom
Conversation
8959de2 to
dffa939
Compare
Also include a setup script to install precommit to operate with the "legacy" hooks.
dffa939 to
c9b418e
Compare
hjmjohnson
left a comment
There was a problem hiding this comment.
@blowekamp I love this idea!!! I have found that pre-commit is much more reliable than our custom built tools. It makes it much easier to keep the codebase clean than does our current system.
After this initial commit is in place, I'd be happy to propose a set of other changes that will make maintenance a lot easier for new developers.
You may be interested in what I did in SimpleITK: |
| cd "${BASH_SOURCE%/*}" && | ||
|
|
||
| # check if python executable exists and is at least MIN_PYTHON_VERSION | ||
| if ! command -v python3 &> /dev/null; then |
There was a problem hiding this comment.
On Windows Git Bash, command -v python3 is going succeed even if Python is not installed or Python is installed but python.exe is not in the PATH. python3 is a non-functional stub that suggests installing Python via the Windows store.
There was a problem hiding this comment.
Do you have a suggestion to what would work here?
There was a problem hiding this comment.
I looked into using uv briefly, but it complained about not being able to find python -- it will require more digging or investigation into other approaches.
There was a problem hiding this comment.
This may work for a local Windows python:
There was a problem hiding this comment.
I have heard that uv has plans to distribute python, too.
There was a problem hiding this comment.
There are two things here: 1) is python3 installed and working and 2) If it's not can the ITK configuration automagically install and use a version of python.
Perhaps we can only address #1 in this initial PR?
There was a problem hiding this comment.
Yes, only 1) can be addressed first, but the commit hook should be optional when python3 is not available (hook setup should or execution should not fail).
There was a problem hiding this comment.
automagically installing python seems frought, there are so many OSes and ways to install python...
There was a problem hiding this comment.
It is not a system install, just a local binary, similar to the commit hooks themselves.
|
@blowekamp Thanks. Superceeded by #5032 and #5013 |
The "pre-commit" be installed congenitally or with the
Utilities/GitSetup/setup-precommitinstallation script.This version of clang-tidy can be run on all files by
pre-commit run -a.