Skip to content

Commit 8fa69df

Browse files
committed
Fix Windows related failures due to line breaks
1 parent 88220b3 commit 8fa69df

File tree

2 files changed

+53
-50
lines changed

2 files changed

+53
-50
lines changed

src/main/scala/sbtghactions/GenerativePlugin.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ ${indent(jobs.map(compileJob(_, sbt)).mkString("\n\n"), 1)}
777777

778778
def compare(file: File, expected: String): Unit = {
779779
val actual = IO.read(file)
780-
if (expected != actual) {
780+
if (removeWindowsLineEndings(expected) != removeWindowsLineEndings(actual)) {
781781
reportMismatch(file, expected, actual)
782782
}
783783
}
@@ -789,8 +789,8 @@ ${indent(jobs.map(compileJob(_, sbt)).mkString("\n\n"), 1)}
789789
})
790790

791791
private[sbtghactions] def diff(expected: String, actual: String): String = {
792-
val expectedLines = expected.split("\n", -1)
793-
val actualLines = actual.split("\n", -1)
792+
val expectedLines = removeWindowsLineEndings(expected).split("\n", -1)
793+
val actualLines = removeWindowsLineEndings(actual).split("\n", -1)
794794
val (lines, _) = expectedLines.zipAll(actualLines, "", "").foldLeft((Vector.empty[String], false)) {
795795
case ((acc, foundDifference), (expectedLine, actualLine)) if expectedLine == actualLine =>
796796
(acc :+ actualLine, foundDifference)
@@ -816,4 +816,7 @@ ${indent(jobs.map(compileJob(_, sbt)).mkString("\n\n"), 1)}
816816
}
817817
lines.mkString("\n")
818818
}
819+
820+
private[sbtghactions] def removeWindowsLineEndings(string: String): String =
821+
string.replaceAll("\\r\\n?","\n")
819822
}

0 commit comments

Comments
 (0)