Skip to content

Add pre-commit hook for automatic Spotless formatting#5

Closed
nlaverdure wants to merge 3 commits into
mainfrom
spotless-pre-commit-hook
Closed

Add pre-commit hook for automatic Spotless formatting#5
nlaverdure wants to merge 3 commits into
mainfrom
spotless-pre-commit-hook

Conversation

@nlaverdure
Copy link
Copy Markdown
Member

Summary

  • Adds .githooks/pre-commit (tracked in the repo) that runs spotlessApply and re-stages any reformatted files before each commit
  • Adds an installHooks Gradle task wired to compileJava that runs git config core.hooksPath .githooks — new contributors get the hook configured automatically on first build, no manual setup required
  • Updates README and CONTRIBUTING to document the hook behavior

Moves the hook into a tracked .githooks/ directory and adds an
installHooks Gradle task (wired to compileJava) that runs
`git config core.hooksPath .githooks` on first build, so new
contributors get the hook automatically without any manual setup.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nlaverdure nlaverdure requested a review from caparomula June 4, 2026 21:14
nlaverdure and others added 2 commits June 4, 2026 17:16
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread .githooks/pre-commit
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that running git diff --name-only | xargs -r git add is quite the right thing. It changes the behavior of git commit to stage all modified files, not just the ones that the user had staged. Second, the xargs invocation will choke on any files with whitespace in their name.

@nlaverdure nlaverdure closed this Jun 5, 2026
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

Successfully merging this pull request may close these issues.

2 participants