I propose that we take this in phases:
- We ask that Contributors install pre-commit, a Python package that aids in the management of pre-commit hooks
- We ask that Contributors install the black and clang-format Python modules (using black 23.x and clang-format 16.x)
- Within the FreeCAD git repository we create .pre-commit-config.yaml to store our default pre-commit configuration. We begin with:
- trailing-whitespace (removes trailing whitespace)
- clang-format, configured to run only on directories in a specific list, whose Maintainers have already applied clang-format on all existing files. Initially that list of directories is empty.
- black, configured to run only on directories in a specific list, whose Maintainers have already applied Black on all existing files. Initially that list of directories is AddonManager and FEM.
- As they have the time and opportunity to do so, Maintainers run clang-format and/or Black as appropriate on the code they are responsible for, in coordination with the other developers working on that code. The commits introducing those formatting changes are added to .git-blame-ignore-revs.
- Once a given subdirectory has been reformatted, it is added to the list in .pre-commit-config.yaml so that the pre-commit hook runs on changed files in that subdirectory from that point forward.
We can also write our own: for example to ensure that copyright headers are in place, or that the copyright on FCStd files is LGPL2-compatible.