webui-dev / webui

Use any web browser or WebView as GUI, with your preferred language in the backend and modern web technologies in the frontend, all in a lightweight portable library.
https://webui.me
MIT License
2.63k stars 157 forks source link

Add pre-commit config #252

Closed ttytm closed 9 months ago

ttytm commented 9 months ago

Adds a pre-commit git hook for clang format.

hassandraga commented 9 months ago

That's mean CI / lint / clang-format (push) will be removed from PR check list?

ttytm commented 9 months ago

Nope, it'll still be there.

This just adds a config for the pre-commit git hook. It's something that will be run locally if a contributor has the pre-commit tool installed when a git commit is made. Then clang format will be run over the committed changes and format them if necessary. So it's just a save guard in case format on save wasn't turned on, or the code wasn't formatted for any other reasons when something was committed.

For the lint workflow I think it's good to see the lint CI failing when code isn't formatted, means it's working :D

But as common as it is to have such a linting and a formatting tool running, I feel it might cause some inconveniences at the time. So the fully automated approach of automatically formatting via CI in case something was committed and not formatted, might really be the way to go. Gonna submit something next days :+1:

hassandraga commented 9 months ago

the lint CI failing when code isn't formatted, means it's working :D

That's the deal! 🤷‍♂️

automatically formatting via CI in case something was committed and not formatted

The main maintainers may use Clang formatting for the next PRs, which I will do. But other contributors may not have any formatting tool so the automatic formatting via CI will be the best option if we can implement it.