laravel / pint

Laravel Pint is an opinionated PHP code style fixer for minimalists.
https://laravel.com/docs/pint
MIT License
2.75k stars 138 forks source link

feat: Add a --with-exit-status flag #270

Closed dshafik closed 4 months ago

dshafik commented 4 months ago

This adds a small feature, --with-exit-status that will exit with either 1 or 0 if there are changed files or not. Essentially this is the same as running with the --test flag except that it also changes the files.

This is helpful for tools such as Captain Hook (or really any pre-commit hook) which rely on the exit code to know if there were changes, so that it will fail and allow amending the commit manually.

it should be noted that while it seems the prevailing consensus is that you should just run pint and then automatically add the changed files to the commit, however if you have additional working changes (e.g. you only staged part of the file, or made changes after staging it) then those changes would now be inadvertently included in the commit.

Happy to add tests if this is a feature you feel would be worth contributing.

Docs PR: laravel/docs#9606

driesvints commented 4 months ago

Hey @dshafik, thanks for the PR! I'll mark this as draft for now as you're still working on this. Feel free to mark as ready when you need another review.

dshafik commented 4 months ago

@driesvints Fixed up the one issue and added tests, this is ready for review now 🙏🏻

taylorotwell commented 4 months ago

Thanks!