Skip to content

Commit

Permalink
Fixed file watcher filtering comparing wrong type of paths
Browse files Browse the repository at this point in the history
  • Loading branch information
JetpackDuba committed Nov 29, 2024
1 parent 372ba1a commit 5c9cc1e
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,29 @@ class FileChangesWatcher @Inject constructor(

override fun detectedChange(paths: Array<String>) {
tabScope.launch {
val hasGitIgnoreChanged = paths.any { it == "$workspacePath$systemSeparator.gitignore" }
val normalizedPaths = paths.map {
it.removePrefix(workspacePath)
}
val hasGitIgnoreChanged = normalizedPaths.any { it == "$systemSeparator.gitignore" }

if (hasGitIgnoreChanged) {
ignoreRules = getIgnoreRulesUseCase(repository)
}

val areAllPathsIgnored = paths.all { path ->
val areAllPathsIgnored = normalizedPaths.all { path ->
val matchesAnyIgnoreRule = ignoreRules.any { rule ->
rule.isMatch(path, Files.isDirectory(Paths.get(path)))
}

val isGitIgnoredFile = gitDirIgnoredFiles.any { ignoredFile ->
"$workspacePath$systemSeparator.git$systemSeparator$ignoredFile" == path
"$systemSeparator.git$systemSeparator$ignoredFile" == path
}

matchesAnyIgnoreRule || isGitIgnoredFile
}

val hasGitDirChanged =
paths.any { it.startsWith("$workspacePath$systemSeparator.git$systemSeparator") }
normalizedPaths.any { it.startsWith("$systemSeparator.git$systemSeparator") }

if (!areAllPathsIgnored) {
println("Emitting changes $hasGitIgnoreChanged")
Expand Down

0 comments on commit 5c9cc1e

Please sign in to comment.