Skip to content

Commit 793e20b

Browse files
committed
Fix issue with root windows drive found in #760
1 parent be2150c commit 793e20b

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
2323
### Fixed
2424
* ktfmt v0.19+ with dropbox-style works again ([#765](https://github.com/diffplug/spotless/pull/765)).
2525
* prettier no longer throws errors on empty files ([#751](https://github.com/diffplug/spotless/pull/751)).
26+
* fixed error when running on root of windows mountpoint ([#760](https://github.com/diffplug/spotless/pull/760)).
2627

2728
## [2.10.2] - 2020-11-16
2829
### Fixed

lib/src/main/java/com/diffplug/spotless/FileSignature.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2020 DiffPlug
2+
* Copyright 2016-2021 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -200,6 +200,9 @@ public static String subpath(String root, String child) {
200200
if (child.startsWith(root)) {
201201
return child.substring(root.length());
202202
} else {
203+
if (machineIsWin() && root.endsWith("://") && child.startsWith(root.substring(0, root.length() - 1))) {
204+
return child.substring(root.length() - 1);
205+
}
203206
throw new IllegalArgumentException("Expected '" + child + "' to start with '" + root + "'");
204207
}
205208
}

plugin-gradle/CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
1414
* `ratchetFrom` now works with git-submodule ([#746](https://github.com/diffplug/spotless/issues/746))
1515
* ktfmt v0.19+ with dropbox-style works again ([#765](https://github.com/diffplug/spotless/pull/765)).
1616
* prettier no longer throws errors on empty files ([#751](https://github.com/diffplug/spotless/pull/751)).
17+
* fixed error when running on root of windows mountpoint ([#760](https://github.com/diffplug/spotless/pull/760)).
1718

1819
## [5.8.2] - 2020-11-16
1920
### Fixed

plugin-maven/CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
1616
* Fix broken test for spotlessFiles parameter on windows ([#737](https://github.com/diffplug/spotless/pull/737))
1717
* ktfmt v0.19+ with dropbox-style works again ([#765](https://github.com/diffplug/spotless/pull/765)).
1818
* prettier no longer throws errors on empty files ([#751](https://github.com/diffplug/spotless/pull/751)).
19+
* fixed error when running on root of windows mountpoint ([#760](https://github.com/diffplug/spotless/pull/760)).
1920

2021
## [2.6.1] - 2020-11-16
2122
### Fixed

testlib/src/test/java/com/diffplug/spotless/FileSignatureTest.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2020 DiffPlug
2+
* Copyright 2016-2021 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525
import java.util.Collections;
2626
import java.util.List;
2727

28+
import org.assertj.core.api.Assertions;
2829
import org.junit.Test;
2930

3031
public class FileSignatureTest extends ResourceHarness {
@@ -79,4 +80,11 @@ private List<File> getTestFiles(final String[] paths) throws IOException {
7980
public void testSubpath() {
8081
assertThat(FileSignature.subpath("root/", "root/child")).isEqualTo("child");
8182
}
83+
84+
@Test
85+
public void windowsRoot() {
86+
org.junit.Assume.assumeTrue(FileSignature.machineIsWin());
87+
String subpath = FileSignature.subpath("S://", "S:/build.gradle");
88+
Assertions.assertThat(subpath).isEqualTo("build.gradle");
89+
}
8290
}

0 commit comments

Comments
 (0)