Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

### Fixed

- git `pre-commit` hook should now work in all worktrees [#605](https://github.com/JLLeitschuh/ktlint-gradle/pull/605)

## [11.0.0] - 2022-08-24

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ internal fun generateGitHook(
echo "Running ktlint over these files:"
echo "${'$'}CHANGED_FILES"

diff=.git/unstaged-ktlint-git-hook.diff
GITDIR=${'$'}(git rev-parse --git-dir)
diff=${'$'}GITDIR/unstaged-ktlint-git-hook.diff

git diff --color=never > ${'$'}diff
if [ -s ${'$'}diff ]; then
git apply -R ${'$'}diff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ class GitHookTasksTest : AbstractPluginTest() {
assertThat(hookText).contains("git apply -R \$diff")
assertThat(hookText).contains("git apply --ignore-whitespace \$diff")
assertThat(hookText).contains("rm \$diff")
assertThat(hookText).contains("GITDIR=\$(git rev-parse --git-dir)")
assertThat(hookText).contains("diff=\$GITDIR/unstaged-ktlint-git-hook.diff")
}
}
}
Expand Down