Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Pre-commit hook not handling multiple files correctly #336

Closed
tvkanters opened this issue Feb 12, 2020 · 0 comments · Fixed by #338
Closed

Pre-commit hook not handling multiple files correctly #336

tvkanters opened this issue Feb 12, 2020 · 0 comments · Fixed by #338
Labels

Comments

@tvkanters
Copy link

On Ubuntu 18.04, after using addKtlintCheckGitPreCommitHook and trying to commit multiple files, the pre-commit hook fails with a message Task 'path/to/second/File.kt' not found in root project 'ProjectName'.

After some investigation, it turns out this is due to this line in the pre-commit hook:

./gradlew --quiet ktlintCheck -PinternalKtlintGitFilter=$CHANGED_FILES

Because there are no quotes around $CHANGED_FILES, the files after the first one were seen as a separate Gradle task. It can be fixed by adding the quotes:

./gradlew --quiet ktlintCheck -PinternalKtlintGitFilter="$CHANGED_FILES"

For now we've got a bash script to patch it:

sed -i 's/\(-PinternalKtlintGitFilter=\)\(\$.*\)$/\1"\2"/' .git/hooks/pre-commit
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants