-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from mezpahlan/windows_support
Experimental Windows support - take 2
- Loading branch information
Showing
10 changed files
with
184 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/util/File.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.dropbox.affectedmoduledetector.util | ||
|
||
import java.io.File | ||
|
||
/** | ||
* Converts a [String] representation of a relative [File] path to sections based on the OS | ||
* specific separator character. | ||
*/ | ||
fun String.toPathSections(rootProjectDir: File, gitRootDir: File): List<String> { | ||
val realSections = toOsSpecificPath() | ||
.split(File.separatorChar) | ||
.toMutableList() | ||
val projectRelativeDirectorySections = rootProjectDir | ||
.toRelativeString(gitRootDir) | ||
.split(File.separatorChar) | ||
for (directorySection in projectRelativeDirectorySections) { | ||
if (realSections.isNotEmpty() && realSections.first() == directorySection) { | ||
realSections.removeAt(0) | ||
} else { | ||
break | ||
} | ||
} | ||
return realSections.toList() | ||
} |
25 changes: 25 additions & 0 deletions
25
affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/util/OsQuirks.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.dropbox.affectedmoduledetector.util | ||
|
||
import java.io.File | ||
|
||
/** | ||
* Returns an OS specific path respecting the separator character for the operating system. | ||
* | ||
* The Git client appears to only talk Unix-like paths however the Gradle client understands all | ||
* OS path variations. This causes issues on systems other than those that use the "/" path | ||
* character i.e. Windows. Therefore we need to normalise the path. | ||
*/ | ||
fun String.toOsSpecificPath(): String { | ||
return this.split("/").joinToString(File.separator) | ||
} | ||
|
||
/** | ||
* Returns a String with an OS specific line endings for the operating system. | ||
* | ||
* The Git client appears to only talk Unix-like line endings ("\n") however the Gradle client | ||
* understands all OS line ending variants. This causes issues on systems other than those that | ||
* use Unix-like line endings i.e. Windows. Therefore we need to normalise the line endings. | ||
*/ | ||
fun String.toOsSpecificLineEnding(): String { | ||
return this.replace("\n", System.lineSeparator()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.