Skip to content

Commit 3d1b6f1

Browse files
committed
Add OS specific handling to executeAndParse
1 parent c10d26a commit 3d1b6f1

File tree

1 file changed

+13
-11
lines changed
  • affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector

1 file changed

+13
-11
lines changed

affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/GitClient.kt

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
package com.dropbox.affectedmoduledetector
2222

2323
import com.dropbox.affectedmoduledetector.commitshaproviders.CommitShaProvider
24+
import com.dropbox.affectedmoduledetector.util.toOsSpecificLineEnding
25+
import com.dropbox.affectedmoduledetector.util.toOsSpecificPath
26+
import org.gradle.api.logging.Logger
2427
import java.io.File
2528
import java.util.concurrent.TimeUnit
26-
import org.gradle.api.logging.Logger
2729

2830
interface GitClient {
2931
fun findChangedFiles(
@@ -83,11 +85,13 @@ internal class GitClientImpl(
8385
val sha = commitShaProvider.get(commandRunner)
8486

8587
// use this if we don't want local changes
86-
return commandRunner.executeAndParse(if (includeUncommitted) {
87-
"$CHANGED_FILES_CMD_PREFIX $sha"
88-
} else {
89-
"$CHANGED_FILES_CMD_PREFIX $top..$sha"
90-
})
88+
return commandRunner.executeAndParse(
89+
if (includeUncommitted) {
90+
"$CHANGED_FILES_CMD_PREFIX $sha"
91+
} else {
92+
"$CHANGED_FILES_CMD_PREFIX $top..$sha"
93+
}
94+
)
9195
}
9296

9397
private fun findGitDirInParentFilepath(filepath: File): File? {
@@ -168,12 +172,10 @@ internal class GitClientImpl(
168172
}
169173

170174
override fun executeAndParse(command: String): List<String> {
171-
val response = execute(command)
175+
return execute(command).toOsSpecificLineEnding()
172176
.split(System.lineSeparator())
173-
.filterNot {
174-
it.isEmpty()
175-
}
176-
return response
177+
.map { it.toOsSpecificPath() }
178+
.filterNot { it.isEmpty() }
177179
}
178180

179181
override fun executeAndParseFirst(command: String): String {

0 commit comments

Comments
 (0)