Skip to content

Commit 32b7a76

Browse files
committed
Add OsQuirks.kt
1 parent b866e57 commit 32b7a76

File tree

1 file changed

+25
-0
lines changed
  • affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/util

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.dropbox.affectedmoduledetector.util
2+
3+
import java.io.File
4+
5+
/**
6+
* Returns an OS specific path respecting the separator character for the operating system.
7+
*
8+
* The Git client appears to only talk Unix-like paths however the Gradle client understands all
9+
* OS path variations. This causes issues on systems other than those that use the "/" path
10+
* character i.e. Windows. Therefore we need to normalise the path.
11+
*/
12+
fun String.toOsSpecificPath(): String {
13+
return this.split("/").joinToString(File.separator)
14+
}
15+
16+
/**
17+
* Returns a String with an OS specific line endings for the operating system.
18+
*
19+
* The Git client appears to only talk Unix-like line endings ("\n") however the Gradle client
20+
* understands all OS line ending variants. This causes issues on systems other than those that
21+
* use Unix-like line endings i.e. Windows. Therefore we need to normalise the line endings.
22+
*/
23+
fun String.toOsSpecificLineEnding(): String {
24+
return this.replace("\n", System.lineSeparator())
25+
}

0 commit comments

Comments
 (0)