Skip to content
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

Add git pre-commit hooks to run tools? #1347

Open
garrettw opened this issue Jan 1, 2025 · 0 comments
Open

Add git pre-commit hooks to run tools? #1347

garrettw opened this issue Jan 1, 2025 · 0 comments
Labels
DX Impacts developer experience enhancement New feature or request low priority does not impact production code needs feedback Requires a greater consensus to make an informed decision

Comments

@garrettw
Copy link
Contributor

garrettw commented Jan 1, 2025

Is your feature request related to a problem? Please describe.
Recently after pushing a commit to a PR, I only discovered after the workflows had run that there were CS issues found by php-cs-fixer -- because I hadn't thought to run that before pushing my commit. I'm remembering to do that now, but...

Describe the solution you'd like
It would be nice if php-cs-fixer would run automatically when I try to make a commit, and either (1) block it if anything needs fixing, or (2) fix it automatically. This can be accomplished by a git pre-commit hook, but that's not something that lives in the repository, so it would only happen on my machine, and anyone else that wanted it would have to set it up for themselves.

At the moment I'm only considering adding php-cs-fixer to the hook and not the integration tests since they take so long. However, the unit tests could potentially be added as well since they run fairly quickly.

Describe alternatives you've considered
Fortunately, there are libraries that allow git hooks to be shared in the repo.
Personally, the only experience I have is with the husky+lint-staged NPM tools, and that is a valid option as it can work for more than just JS files.
However, there are also PHP-based tools that can do this:

So my questions are:

  • What does anyone think about adding something like this?
  • Which of the 4 options above seems best?
@garrettw garrettw added enhancement New feature or request low priority does not impact production code needs feedback Requires a greater consensus to make an informed decision DX Impacts developer experience labels Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Impacts developer experience enhancement New feature or request low priority does not impact production code needs feedback Requires a greater consensus to make an informed decision
Projects
None yet
Development

No branches or pull requests

1 participant