-
-
Notifications
You must be signed in to change notification settings - Fork 316
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
utils: sync grass_clang_format script to pre-commit config #4186
Conversation
A conceptual question here: Where is this internal script used, and by who? It isn't used anymore in our day to day development as I can see from the last year. So, if it isn't maintained nor used, we should simply remove it. It seems to be a utility script, purpose based at the time. |
As long as using pre-commit is not a requirement this script may have its use. |
I would not remove it as in the past (talking about 20+ years) we occasionally formatted incoming code contributions easily. Likely incoming new code is not formatted according to our standards. It is true that it isn't frequently used but still it more of a hassle to reinvent it/dig in old versions once the script is gone. Bonus: we can also format the "main" addons and even GRASS GIS related code in other repos easily. |
We enforce the style in CI anyways, so all code is required to follow the format defined by the clang-format tool at XX version with the config file. It doesn't matter from where is done. We already offer suggestions in CI (not just failing without saying what should be), we offer to download the diff as a patch to apply, we offer to download all the changed files to unzip in the repo and commit, we maintain pre-commit config. So, who still uses that script daily (or even monthly)? |
Random example: we have many addon repos here: https://github.com/mundialis/ - all waiting to be reformatted. This is best done before sending it to CI, through the script. |
A problem with a script like this one, when we enforce a specific version for the complete repo, is that there is no simple way to have the correct clang-format for everyone, everywhere, in every distro + distro release + arch, without changing distro release. For example, Ubuntu noble (24.04) only had clang-format 16 or clang-format 18, and not the clang-format 17 we were using in the last couple of months. Ubuntu jammy (22.04) only has clang format 14, that didn't even match the clang-format 15 that we required for a long time before I was more active here. Precommit solves this by using a pip-bundled statically linked version for use of a single version. |
This script exists for corner cases. This updates it to use the version stated in pre-commits configs (= minimal to zero maintenance), it is up to the user to install the version needed (any version is easily installed via pip). |
I see how for corner cases, external uses and posterity it might be useful to keep. There wasn't a problem with the PR itself, but an opportunity to discuss its maintenance and relevance. So only question left is: Should the fallback version "18" absolutely kept in sync in the future, or it can end up outdated a bit? If it is needed to keep updated, we can wire it up with renovate (a regex, we could use an adaptation of the default one used for docker/regex manager, but only indicate to check in this file too + change the regex to not look for ARG or ENV, but |
Right after knowing that I'll place my approval :) |
As long as the .pre-commit-config.yaml doesn't change the structure, the Before we merge this, the script need to tested on a non-BSD system (i.e. GNU, e.g. linux). |
You use BSD daily? |
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.
Once tested on non-BSD system, it is ok to merge
The mac flavour of it, yes. |
Thanks for testing! |
I didn't test it myself. Once it was tested, it would have been ok to merge. |
Oh dear, I misunderstood. |
BTW, I don't use it and don't plan to. pre-commit works well. Nevertheless, I had to do
pre-commit is really the better solution for that. It goes over many things, not just formatting. |
To keep
./utils/grass_clang_format.sh
shell script in sync with pre-commit configuration, the ClangFormat version is taken from.pre-commit-config.yaml
.