-
-
Notifications
You must be signed in to change notification settings - Fork 664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Add pre-commit configuration file to run clang-format #4651
base: master
Are you sure you want to change the base?
ENH: Add pre-commit configuration file to run clang-format #4651
Conversation
8959de2
to
dffa939
Compare
Also include a setup script to install precommit to operate with the "legacy" hooks.
dffa939
to
c9b418e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a suggestion to what would work here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may work for a local Windows python:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have heard that uv
has plans to distribute python, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
automagically installing python seems frought, there are so many OSes and ways to install python...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not a system install, just a local binary, similar to the commit hooks themselves.
The "pre-commit" be installed congenitally or with the
Utilities/GitSetup/setup-precommit
installation script.This version of clang-tidy can be run on all files by
pre-commit run -a
.