Skip to content

fixes #2585: Make spotlessInstallGitPrePushHook task compatible with Gradle configuration cache #2586

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
* Adds support for worktrees (fixes [#1765](https://github.com/diffplug/spotless/issues/1765))
* Bump default `google-java-format` version to latest `1.24.0` -> `1.28.0`. ([#2345](https://github.com/diffplug/spotless/pull/2345))
* Bump default `ktlint` version to latest `1.5.0` -> `1.7.1`. ([#2555](https://github.com/diffplug/spotless/pull/2555))
* Make Git pre-push hook install task (`spotlessInstallGitPrePushHook`) compatible with the Gradle configuration cache. ([#2585](https://github.com/diffplug/spotless/issues/2585))

## [3.3.1] - 2025-07-21
### Fixed
Expand Down
1 change: 1 addition & 0 deletions plugin-gradle/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
* Bump default `ktlint` version to latest `1.5.0` -> `1.7.1`. ([#2555](https://github.com/diffplug/spotless/pull/2555))
### Fixed
* Respect system gitconfig when performing git operations ([#2404](https://github.com/diffplug/spotless/issues/2404))
* Make Git pre-push hook install task (`spotlessInstallGitPrePushHook`) compatible with the Gradle configuration cache. ([#2585](https://github.com/diffplug/spotless/issues/2585))

## [7.2.1] - 2025-07-21
### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public SpotlessExtensionImpl(Project project) {
task.setGroup(TASK_GROUP); // no description on purpose
});
rootInstallPreHook = project.getTasks().register(EXTENSION + INSTALL_GIT_PRE_PUSH_HOOK, SpotlessInstallPrePushHookTask.class, task -> {
task.rootDir = project.getRootDir();
task.setGroup(BUILD_SETUP_TASK_GROUP);
task.setDescription(INSTALL_GIT_PRE_PUSH_HOOK_DESCRIPTION);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.diffplug.gradle.spotless;

import java.io.File;

import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.TaskAction;
import org.gradle.work.DisableCachingByDefault;
Expand All @@ -32,6 +34,8 @@
@DisableCachingByDefault(because = "not worth caching")
public class SpotlessInstallPrePushHookTask extends DefaultTask {

File rootDir;

/**
* Executes the task to install the Git pre-push hook.
*
Expand Down Expand Up @@ -60,7 +64,7 @@ public void error(String format, Object... arguments) {
}
};

final var installer = new GitPrePushHookInstallerGradle(logger, getProject().getRootDir());
final var installer = new GitPrePushHookInstallerGradle(logger, rootDir);
installer.install();
}
}