Skip to content

Commit 58931b3

Browse files
authored
Fix the GitRatchet problem on bare checkouts. (#611)
* Fix the GitRatchet problem on bare checkouts. * Update changelog.
1 parent e7dbfc8 commit 58931b3

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

plugin-gradle/CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
88
* This removes the dependency to the no-longer-maintained Linux/Windows/macOs variants of J2V8.
99
* This enables spotless to use the latest `prettier` versions (instead of being stuck at prettier version <= `1.19.0`)
1010
* Bumped default versions, prettier `1.16.4` -> `2.0.5`, tslint `5.12.1` -> `6.1.2`
11+
### Fixed
12+
* Using `ratchetFrom 'origin/main'` on a bare checkout generated a cryptic error, now generates a clear error. ([#608](https://github.com/diffplug/spotless/issues/608))
1113

1214
## [4.3.0] - 2020-06-05
1315
### Deprecated

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GitRatchet.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,16 @@ private Repository repositoryFor(Project project) throws IOException {
152152
}
153153

154154
private static @Nullable Repository traverseParentsUntil(File startWith, File file) throws IOException {
155-
do {
155+
while (startWith != null) {
156156
if (isGitRoot(startWith)) {
157157
return createRepo(startWith);
158158
} else {
159159
startWith = startWith.getParentFile();
160+
if (Objects.equals(startWith, file)) {
161+
return null;
162+
}
160163
}
161-
} while (!Objects.equals(startWith, file));
164+
}
162165
return null;
163166
}
164167

0 commit comments

Comments
 (0)