Skip to content

Commit b040d90

Browse files
committed
To avoid issues with Git for Windows autocrlf it is safer to clean up any windows line breaks when reading an existing violations file (the files will still count as modified to Git in this case because the line breaks have changed from crlf to lf, but at least the test does not fail in strange ways)
Signed-off-by: Peter Gafert <[email protected]>
1 parent a88fb1f commit b040d90

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

archunit/src/main/java/com/tngtech/archunit/library/freeze/ViolationStoreFactory.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,24 @@ public List<String> getViolations(ArchRule rule) {
155155
}
156156

157157
private List<String> readLines(String ruleDetailsFileName) {
158+
String violationsText = readStoreFile(ruleDetailsFileName);
159+
List<String> lines = Splitter.on(UNESCAPED_LINE_BREAK_PATTERN).splitToList(violationsText);
160+
return unescape(lines);
161+
}
162+
163+
private String readStoreFile(String fileName) {
158164
try {
159-
String violationsText = new String(toByteArray(new File(storeFolder, ruleDetailsFileName)), UTF_8);
160-
List<String> lines = Splitter.on(UNESCAPED_LINE_BREAK_PATTERN).splitToList(violationsText);
161-
return unescape(lines);
165+
String result = new String(toByteArray(new File(storeFolder, fileName)), UTF_8);
166+
return ensureUnixLineBreaks(result);
162167
} catch (IOException e) {
163168
throw new StoreReadException(e);
164169
}
165170
}
166171

172+
private String ensureUnixLineBreaks(String string) {
173+
return string.replaceAll("\r\n", "\n");
174+
}
175+
167176
private static class FileSyncedProperties {
168177
private final File propertiesFile;
169178
private final Properties loadedProperties;

0 commit comments

Comments
 (0)