Skip to content

Commit 0cb7012

Browse files
committed
Fixed file watcher filtering comparing wrong type of paths
1 parent 038603c commit 0cb7012

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/main/kotlin/com/jetpackduba/gitnuro/git/FileChangesWatcher.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,29 @@ class FileChangesWatcher @Inject constructor(
4747

4848
override fun detectedChange(paths: Array<String>) {
4949
tabScope.launch {
50-
val hasGitIgnoreChanged = paths.any { it == "$workspacePath$systemSeparator.gitignore" }
50+
val normalizedPaths = paths.map {
51+
it.removePrefix(workspacePath)
52+
}
53+
val hasGitIgnoreChanged = normalizedPaths.any { it == "$systemSeparator.gitignore" }
5154

5255
if (hasGitIgnoreChanged) {
5356
ignoreRules = getIgnoreRulesUseCase(repository)
5457
}
5558

56-
val areAllPathsIgnored = paths.all { path ->
59+
val areAllPathsIgnored = normalizedPaths.all { path ->
5760
val matchesAnyIgnoreRule = ignoreRules.any { rule ->
5861
rule.isMatch(path, Files.isDirectory(Paths.get(path)))
5962
}
6063

6164
val isGitIgnoredFile = gitDirIgnoredFiles.any { ignoredFile ->
62-
"$workspacePath$systemSeparator.git$systemSeparator$ignoredFile" == path
65+
"$systemSeparator.git$systemSeparator$ignoredFile" == path
6366
}
6467

6568
matchesAnyIgnoreRule || isGitIgnoredFile
6669
}
6770

6871
val hasGitDirChanged =
69-
paths.any { it.startsWith("$workspacePath$systemSeparator.git$systemSeparator") }
72+
normalizedPaths.any { it.startsWith("$systemSeparator.git$systemSeparator") }
7073

7174
if (!areAllPathsIgnored) {
7275
println("Emitting changes $hasGitIgnoreChanged")

0 commit comments

Comments
 (0)