From e7a557c30562eb9db8f8894808ef0876298672ea Mon Sep 17 00:00:00 2001 From: Abdelilah El Aissaoui Date: Sat, 15 Jul 2023 13:56:02 +0200 Subject: [PATCH] Fixed exclude file being null not handled --- .../git/workspace/GetIgnoreRulesUseCase.kt | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/git/workspace/GetIgnoreRulesUseCase.kt b/src/main/kotlin/com/jetpackduba/gitnuro/git/workspace/GetIgnoreRulesUseCase.kt index d0a7cda..f740fec 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/git/workspace/GetIgnoreRulesUseCase.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/git/workspace/GetIgnoreRulesUseCase.kt @@ -29,20 +29,22 @@ class GetIgnoreRulesUseCase @Inject constructor() { } if (baseConfig != null) { - var excludesFilePath = baseConfig.getString("core", null, "excludesFile") + var excludesFilePath = baseConfig.getString("core", null, "excludesFile") ?: "" - if (excludesFilePath.startsWith("~")) { - excludesFilePath = excludesFilePath.replace("~", System.getProperty("user.home").orEmpty()) - } + if (excludesFilePath.isNotEmpty()) { + if (excludesFilePath.startsWith("~")) { + excludesFilePath = excludesFilePath.replace("~", System.getProperty("user.home").orEmpty()) + } - val excludesFile = FileSystems - .getDefault() - .getPath(excludesFilePath) - .normalize() - .toFile() + val excludesFile = FileSystems + .getDefault() + .getPath(excludesFilePath) + .normalize() + .toFile() - if (excludesFile.exists() && excludesFile.isFile) { - ignoreLines.addAll(excludesFile.readLines()) + if (excludesFile.exists() && excludesFile.isFile) { + ignoreLines.addAll(excludesFile.readLines()) + } } }