Skip to content

Commit

Permalink
Merge branch 'main' into av/ktlint-experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg authored Apr 22, 2022
2 parents 247939d + 53673d3 commit 672bf30
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion plugin-gradle/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (

## [Unreleased]
### Added
* Added a runToFixMessage property to customize the run-to-fix message in spotlessCheck task ([#1175](https://github.com/diffplug/spotless/issues/1175)).
* Added support for enabling ktlint experimental ruleset. ([#1145](https://github.com/diffplug/spotless/pull/1168))

## [6.4.2] - 2022-04-06

### Fixed
* Git user config and system config also included for defaultEndings configuration. ([#540](https://github.com/diffplug/spotless/issues/540))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2021 DiffPlug
* Copyright 2016-2022 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,6 +29,7 @@
import org.gradle.api.file.FileVisitDetails;
import org.gradle.api.file.FileVisitor;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.TaskAction;

Expand All @@ -40,6 +41,9 @@ public abstract class SpotlessCheck extends SpotlessTaskService.ClientTask {
@Internal
public abstract Property<String> getEncoding();

@Input
public abstract Property<String> getRunToFixMessage();

public void performActionTest() throws IOException {
performAction(true);
}
Expand Down Expand Up @@ -98,7 +102,7 @@ public void visitFile(FileVisitDetails fileVisitDetails) {
if (!problemFiles.isEmpty()) {
Collections.sort(problemFiles);
throw new GradleException(DiffMessageFormatter.builder()
.runToFix("Run '" + calculateGradleCommand() + " " + getTaskPathPrefix() + "spotlessApply' to fix these violations.")
.runToFix(getRunToFixMessage().get())
.formatterFolder(
getProjectDir().get().getAsFile().toPath(),
getSpotlessOutDirectory().get().toPath(),
Expand All @@ -117,6 +121,8 @@ void init(SpotlessTaskImpl impl) {
super.init(impl);
getProjectPath().set(getProject().getPath());
getEncoding().set(impl.getEncoding());
getRunToFixMessage().convention(
"Run '" + calculateGradleCommand() + " " + getTaskPathPrefix() + "spotlessApply' to fix these violations.");
}

private String getTaskPathPrefix() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2021 DiffPlug
* Copyright 2016-2022 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -135,6 +135,19 @@ void lineEndingProblem() throws Exception {
" +C\\n");
}

@Test
void customRunToFixMessage() throws Exception {
Bundle task = create(setFile("testFile").toContent("A\r\nB\r\nC\r\n"));
String customMessage = "Formatting issues detected, please read automatic-code-formatting.txt and correct.";
task.check.getRunToFixMessage().set(customMessage);

String msg = task.checkFailureMsg();

String firstLine = "The following files had format violations:\n";
String lastLine = "\n" + customMessage;
Assertions.assertThat(msg).startsWith(firstLine).endsWith(lastLine);
}

@Test
void whitespaceProblem() throws Exception {
Bundle spotless = create(setFile("testFile").toContent("A \nB\t\nC \n"));
Expand Down
4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pluginManagement {
plugins {
id 'com.diffplug.spotless' version '6.4.1'
id 'com.diffplug.spotless' version '6.4.2'
// https://plugins.gradle.org/plugin/com.gradle.plugin-publish
id 'com.gradle.plugin-publish' version '0.21.0'
// https://github.com/gradle-nexus/publish-plugin/releases
Expand All @@ -12,7 +12,7 @@ pluginManagement {
// https://github.com/diffplug/goomph/blob/main/CHANGES.md
id 'com.diffplug.p2.asmaven' version '3.27.0' // DO NOT UPDATE, see https://github.com/diffplug/spotless/pull/874
// https://github.com/gradle/test-retry-gradle-plugin/releases
id 'org.gradle.test-retry' version '1.3.1'
id 'org.gradle.test-retry' version '1.3.2'
// https://github.com/radarsh/gradle-test-logger-plugin/blob/develop/CHANGELOG.md
id 'com.adarshr.test-logger' version '3.2.0'
}
Expand Down

0 comments on commit 672bf30

Please sign in to comment.