-
-
Notifications
You must be signed in to change notification settings - Fork 117
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
Feature request: pre-commit hook for formatter #535
Comments
Thanks for the suggestion! I guess this needs both the creation of some files in this repo and a PR for the pre-commit repository. This project is currently passively maintained, so only bugs are fixed. New functionalities need a PR contribution. Feel free to open one if you get the chance. |
@maresb you can use mine if want: https://github.com/nikaro/taplo-pre-commit Beware that the Docker hooks don't work on arm64 machines, until the next release of Taplo, cf. this issue. The native Rust ones are fine, but the build will take a lot of time the first time you run it (after that it should be in your cache so it will be ok). Feel free to reuse it to open a PR here if you want. |
Thanks @nikaro, I just now got around to trying this out. My experience is that it was going very slowly during the initial install. My suspicion is that pre-commit was downloading a rust toolchain in the background, and that's why it's so slow. I was wondering what's the purpose of your Docker hooks, but if I understood the above correctly then it saves on all the compile time. Running Docker from pre-commit seems pretty crazy to me. I wish it could just download binaries and use those. Unfortunately I'm not familiar with rust development, so I have no sense of the challenges of doing this. Speaking of which, there are supposed to be binary releases but it seems like the links are broken and no binary artifacts are being generated by the GitHub workflows. Should I open a separate issue for that? |
You are right that's what's happening: downloading rust toolchain and compiling. And that's why the
There is PR for that in pre-commit bit it seems a bit stale lately... :-/
Yep, looks like the release workflow is broken: https://github.com/tamasfe/taplo/actions/runs/7742605055/workflow#L268 |
A solution is being prepared in #549. That's just the Python package, providing a pre-commit hook is the next step and should be quite easy. A test version of such a hook is available in ComPWA/taplo-pre-commit#13 (comment) |
As a stopgap I quickly threw together a hook that uses the binaries published to NPM: https://github.com/mdekstrand/taplo-pre-commit |
Since #549 is merged, Taplo will be published as a PyPI package on https://pypi.org/project/taplo. One could add a Edit: The repo has been renamed to github.com/ComPWA/taplo-pre-commit, but you will be redirected automatically. |
Incredible work @redeboer, I appreciate all the persistence it took to get this done!!! I have started to use https://github.com/ComPWA/mirrors-taplo as a pre-commit hook and it's working beautifully!
👍 |
Once that happens, https://github.com/ComPWA/mirrors-taplo can deprecate itself with a reference to the official one. /edit: seems like auto-updating the URL isn’t supported? Seems like |
@redeboer could you please just archive the project next time? Deleting it just broke our - and I guess many more - CI pipelines 😉 |
I'm pretty confused by the last two comments. @flying-sheep, what's wrong with autoupdate? Seems to work for me (maybe @redeboer already fixed the issue)? Also, @MaxWinterstein, what do you mean, are you referring to ComPWA/taplo-pre-commit#18? Maybe these should be issues in https://github.com/ComPWA/taplo-pre-commit? |
Sorry about that. It was a fork that was meant for testing #549 (comment). It's back online now and I'll archive it.
Yeah probably better to post there. Once/if there is an official taplo/toml-formatter organisation (#403 (comment)) that can host this hook, I'm happy to transfer that repo there. |
I was responding to redeboer’s statement “[it] would be better to set up an official repo [for the pre-commit hook mirror]” Once that exists, ComPWA/taplo-pre-commit is duplicate. |
It would be great if there were a pre-commit hook for the TOML formatter. My current go-to formatter is
pretty-format-toml
, but this suffers from a fairly serious issue that comments are sometimes deleted. If this were implemented, I think it could easily become the best formatter with a pre-commit hook.The text was updated successfully, but these errors were encountered: