File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/util Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 1+ package com.dropbox.affectedmoduledetector.util
2+
3+ import java.io.File
4+
5+ /* *
6+ * Converts a [String] representation of a relative [File] path to sections based on the OS
7+ * specific separator character.
8+ */
9+ fun String.toPathSections (rootProjectDir : File , gitRootDir : File ): List <String > {
10+ val realSections = toOsSpecificPath()
11+ .split(File .separatorChar)
12+ .toMutableList()
13+ val projectRelativeDirectorySections = rootProjectDir
14+ .toRelativeString(gitRootDir)
15+ .split(File .separatorChar)
16+ for (directorySection in projectRelativeDirectorySections) {
17+ if (realSections.isNotEmpty() && realSections.first() == directorySection) {
18+ realSections.removeAt(0 )
19+ } else {
20+ break
21+ }
22+ }
23+ return realSections.toList()
24+ }
You can’t perform that action at this time.
0 commit comments