Skip to content

Commit a383ccf

Browse files
committed
Respond to PR review:
- Use printError instead of println - Revert formatting of Status.kt - Change RefreshType to NONE
1 parent 06aa3db commit a383ccf

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

src/main/kotlin/com/jetpackduba/gitnuro/extensions/FileExtensions.kt

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
package com.jetpackduba.gitnuro.extensions
22

3+
import com.jetpackduba.gitnuro.logging.printError
4+
import com.jetpackduba.gitnuro.system.OS
5+
import com.jetpackduba.gitnuro.system.currentOs
36
import kotlinx.io.IOException
47
import java.awt.Desktop
58
import java.io.File
6-
import java.util.*
9+
10+
private const val TAG = "FileExtensions"
711

812
fun File.openDirectory(dirName: String): File {
913
val newDir = File(this, dirName)
@@ -18,7 +22,7 @@ fun File.openDirectory(dirName: String): File {
1822
fun File.openFileInFolder() {
1923

2024
if (!exists() || !isDirectory) {
21-
println("Folder with path $path does not exist or is not a folder")
25+
printError(TAG, "Folder with path $path does not exist or is not a folder")
2226
return
2327
}
2428

@@ -31,25 +35,25 @@ fun File.openFileInFolder() {
3135
}
3236
}
3337
} catch (e: Exception) {
34-
println("Desktop API failed: ${e.message}")
38+
printError(TAG, "Desktop API failed: ${e.message}")
3539
}
3640

3741
// Fallback
38-
val os = System.getProperty("os.name").lowercase(Locale.getDefault())
39-
val command = when {
40-
os.contains("linux") -> listOf("xdg-open", absolutePath)
41-
os.contains("mac") -> listOf("open", absolutePath)
42-
os.contains("windows") -> listOf("explorer", absolutePath)
42+
val os = currentOs
43+
val command = when (os) {
44+
OS.LINUX -> listOf("xdg-open", absolutePath)
45+
OS.MAC -> listOf("open", absolutePath)
46+
OS.WINDOWS -> listOf("explorer", absolutePath)
4347
else -> null
4448
}
4549

4650
if (command != null) {
4751
try {
4852
ProcessBuilder(command).start()
4953
} catch (ex: IOException) {
50-
println("Failed to open file explorer: ${ex.message}")
54+
printError(TAG, "Failed to open file explorer: ${ex.message}")
5155
}
5256
} else {
53-
println("Unsupported OS: $os")
57+
printError(TAG, "Unsupported OS: $os")
5458
}
5559
}

src/main/kotlin/com/jetpackduba/gitnuro/git/workspace/Status.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
66
import com.jetpackduba.gitnuro.extensions.icon
77
import com.jetpackduba.gitnuro.extensions.iconColor
88

9-
data class StatusEntry(
10-
val filePath: String,
11-
val statusType: StatusType
12-
) {
9+
data class StatusEntry(val filePath: String, val statusType: StatusType) {
1310
val icon: ImageVector
1411
get() = statusType.icon
1512

src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/CommitChangesViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class CommitChangesViewModel @Inject constructor(
158158
}
159159

160160
fun openFileInFolder(folderPath: String?) = tabState.runOperation(
161-
refreshType = RefreshType.UNCOMMITTED_CHANGES,
161+
refreshType = RefreshType.NONE,
162162
) {
163163
folderPath?.let { File(it).openFileInFolder() }
164164
}

src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/StatusViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ class StatusViewModel @Inject constructor(
513513
}
514514

515515
fun openFileInFolder(folderPath: String?) = tabState.runOperation(
516-
refreshType = RefreshType.UNCOMMITTED_CHANGES,
516+
refreshType = RefreshType.NONE,
517517
) {
518518
folderPath?.let { File(it).openFileInFolder() }
519519
}

0 commit comments

Comments
 (0)