Still haven't landed on a good solution to format files with a git commit hook. I want it to support partial commits too, which my current pre-commit script running ktfmt doesn't.

I think python pre-commit also does not do what I want and it introduces a new dependency.

Spotless has a pre-push hook but (unlike younger me) I just want commit and have the files formatted, not just checked.

There's lint-staged and husky for node but for Gradle I've not found much. What are y'all using?

@botteaap This python script might help! It runs per-file though, so using gradle to format is slow. We use ktfmt at work to format things, and while our CI runs this through gradle, our pre-commit hook runs the ktfmt jar locally. We check the jar into the repo (in git lfs I think) to keep it in sync.

https://github.com/hallettj/git-format-staged

GitHub - hallettj/git-format-staged: Git command to transform staged files using a formatting command

Git command to transform staged files using a formatting command - hallettj/git-format-staged

GitHub