diff --git a/src/main/kotlin/com/dohyeon5626/service/impl/FileServiceImpl.kt b/src/main/kotlin/com/dohyeon5626/service/impl/FileServiceImpl.kt index 69b1a9d..4e2da8a 100644 --- a/src/main/kotlin/com/dohyeon5626/service/impl/FileServiceImpl.kt +++ b/src/main/kotlin/com/dohyeon5626/service/impl/FileServiceImpl.kt @@ -1,20 +1,15 @@ package com.dohyeon5626.service.impl import com.dohyeon5626.service.FileService -import com.intellij.openapi.project.Project -import com.intellij.openapi.project.ProjectManager import com.intellij.openapi.vfs.LocalFileSystem import java.io.File -import java.nio.file.FileSystems -import kotlin.io.path.Path class FileServiceImpl: FileService { private val fileSystem = LocalFileSystem.getInstance() override fun generateGitKeep(path: String) { - path.takeIf { !isGitIgnorePath("$path/.gitkeep") } - ?.let { File(it).listFiles() } + path.let { File(it).listFiles() } ?.apply { if (isEmpty()) { createFile("$path/.gitkeep") @@ -25,8 +20,7 @@ class FileServiceImpl: FileService { } override fun generateGitKeepInAllSubfolder(path: String) { - path.takeIf { !isGitIgnorePath("$path/.gitkeep") } - ?.let { File(it).listFiles() } + path.let { File(it).listFiles() } ?.apply { if (isEmpty()) { createFile("$path/.gitkeep") @@ -49,22 +43,4 @@ class FileServiceImpl: FileService { fileSystem.refreshAndFindFileByIoFile(file)?.refresh(true, false) } - private fun isGitIgnorePath(path: String): Boolean { - getProject(path)?.basePath?.let { - return File("${it}/.gitignore").readLines() - .filter { line -> line.isNotEmpty() && !line.startsWith("#") } - .any { ignorePattern -> isGitIgnorePatternMatch(ignorePattern, path.replace("$it/", "")) } - } - return false - } - - private fun isGitIgnorePatternMatch(ignorePattern: String, path: String) = - FileSystems.getDefault().getPathMatcher("glob:$ignorePattern").matches(Path(path)) - - private fun getProject(path: String): Project? { - ProjectManager.getInstance().openProjects.toList() - .forEach { if(it.basePath != null && path.contains(it.basePath!!)) return it } - return null - } - } \ No newline at end of file