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

Git hooks should only check staged/committed files #10

Closed
programLyrique opened this issue Mar 7, 2024 · 2 comments
Closed

Git hooks should only check staged/committed files #10

programLyrique opened this issue Mar 7, 2024 · 2 comments

Comments

@programLyrique
Copy link
Collaborator

The git hooks perform checks and tests on changes they are not supposed to check.

The pre-commit one should only perform checks (such as the formatting one) on the files added to the staging area.

The pre-push should perform checks and tests on the last commit, not on changes that have not been committed.

@Jakobeha
Copy link
Contributor

Jakobeha commented Mar 7, 2024

The pre-push hook was removed, but Git doesn't propagate hooks so you must run rm .git/hooks/pre-push.sh. Sorry about that.

I just fixed the pre-commit in main (#11) so it only applies to staged files unless everything is staged, and can also auto-format the staged files instead of just throwing an error. I kept it so that it formats everything if everything is staged (even non-committed files) because it's apparently recommended, and spotless already caches so that it shouldn't be slower unless something mis-formatted is already comitted (see diffplug/spotless#178).

@programLyrique
Copy link
Collaborator Author

Thanks!

(I think the one to remove for pre-pushing is .githooks/pre-push.sh)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants