-
Notifications
You must be signed in to change notification settings - Fork 281
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
Move style checks to pre-commit #103
Conversation
Also adds a check for cmake-format.
.pre-commit-config.yaml
Outdated
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- id: check-added-large-files | ||
- repo: https://github.com/pre-commit/mirrors-clang-format | ||
rev: 'v14.0.0' | ||
rev: v16.0.0 |
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 I'd keep 14, just because is the default version of Ubuntu 22.04, it might break with newer versions
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.
Alright, will revert it then.
How does a failure case look like? Is it clear if the failure is on black or any formatter? Would you mind providing a screenshot or something similar |
@ahans sorry I just merged main again into this branch. I keep accidentally pushing the damn button 😂. I still can't believe I can merge stuff into your private repo 😱. Sorry I did it twice 😔 |
Here's an example where I messed up the formatting of some Python file: It checks and fixes in one go, so next time I run it everything would be green again. That's something I disliked at first. I would have preferred some "check only" mode. But having used it for a while it's actually not an issue at all in my workflow. For most file types I have some "format on change" enabled anyways, but occasionally it does happen that something does not get formatted properly. Then I see that the "pre-commit" stage in CI is red and I want to run "fix" locally anyways. Really can't think of a reason why I would want a "check" only. It would always be followed by a "fix" anyways. |
No worries, I left the option checked that allows you (or any other maintainer) to make edits. I think it's fairly reasonable. Otherwise you would have to rely on me for everything (or copy my branch into your own and open up another PR). |
Deswegen! Now I get it. Much easier to work like this. Thanks! |
If you do |
56b3ca9
to
858dd23
Compare
I think is ready to merge @ahans . If you agree let me know because I need to change some config on the GH side |
I've never run
I reverted the clang-format version now and also changed the config for when to run the workflow to match the other ones. So yes, from my end I would say it's ready. |
I also rebased onto latest |
yup, cuz I squash and merge always anyways |
This is roughly what I had in mind. It allows you to maintain only
.pre-commit-config.yaml
for all style checks. The GH action runs it in CI, manually you can justpre-commit run [--all]
and don't have to manage tools or anything manually. It's all taken care of by pre-commit.Just putting this up to show what I was talking about. No need to merge this if you don't like it.