Skip to content

Commit e9e1a01

Browse files
committed
Removed ignoreFile with file path.
1 parent f0dfc03 commit e9e1a01

File tree

1 file changed

+2
-6
lines changed
  • plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util

1 file changed

+2
-6
lines changed

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/GitIgnoreFilteringUtil.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import com.intellij.openapi.vfs.VfsUtil
77
import com.intellij.openapi.vfs.VirtualFile
88
import kotlinx.coroutines.async
99
import kotlinx.coroutines.withContext
10-
import java.nio.file.Paths
1110
import kotlin.coroutines.coroutineContext
12-
import kotlin.io.path.relativeTo
1311

1412
class GitIgnoreFilteringUtil(private val moduleDir: VirtualFile) {
1513
private var ignorePatternsWithGitIgnore = emptyList<Regex>()
@@ -80,9 +78,7 @@ class GitIgnoreFilteringUtil(private val moduleDir: VirtualFile) {
8078
.replace("*", ".*")
8179
.let { if (it.endsWith("/")) "$it.*" else "$it/.*" } // Add a trailing /* to all patterns. (we add a trailing / to all files when matching)
8280

83-
suspend fun ignoreFile(file: VirtualFile): Boolean = ignoreFile(file.presentableUrl)
84-
85-
suspend fun ignoreFile(path: String): Boolean {
81+
suspend fun ignoreFile(file: VirtualFile): Boolean {
8682
// this method reads like something a JS dev would write and doesn't do what the author thinks
8783
val deferredResults = ignorePatternsWithGitIgnore.map { pattern ->
8884
withContext(coroutineContext) {
@@ -91,7 +87,7 @@ class GitIgnoreFilteringUtil(private val moduleDir: VirtualFile) {
9187
// we convert the glob rules to regex, add a trailing /* to all rules and then match
9288
// entries against them by adding a trailing /.
9389
// TODO: Add unit tests for gitignore matching
94-
val relative = if (path.startsWith(moduleDir.presentableUrl)) Paths.get(path).relativeTo(moduleDir.toNioPath()) else path
90+
val relative = getRelativePath(file)
9591
async { pattern.matches("$relative/") }
9692
}
9793
}

0 commit comments

Comments
 (0)