Excluded git message files from file detection
This commit is contained in:
parent
11ca59eed9
commit
a951d9ccd1
@ -8,6 +8,7 @@ import kotlinx.coroutines.flow.SharedFlow
|
|||||||
import kotlinx.coroutines.isActive
|
import kotlinx.coroutines.isActive
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
import org.eclipse.jgit.lib.Constants
|
||||||
import org.eclipse.jgit.lib.Repository
|
import org.eclipse.jgit.lib.Repository
|
||||||
import uniffi.gitnuro.WatchDirectoryNotifier
|
import uniffi.gitnuro.WatchDirectoryNotifier
|
||||||
import uniffi.gitnuro.watchDirectory
|
import uniffi.gitnuro.watchDirectory
|
||||||
@ -28,6 +29,12 @@ class FileChangesWatcher @Inject constructor(
|
|||||||
pathStr: String
|
pathStr: String
|
||||||
) = withContext(Dispatchers.IO) {
|
) = withContext(Dispatchers.IO) {
|
||||||
var ignoreRules = getIgnoreRulesUseCase(repository)
|
var ignoreRules = getIgnoreRulesUseCase(repository)
|
||||||
|
val gitDirIgnoredFiles = listOf(
|
||||||
|
Constants.COMMIT_EDITMSG,
|
||||||
|
Constants.MERGE_MSG,
|
||||||
|
Constants.SQUASH_MSG,
|
||||||
|
)
|
||||||
|
|
||||||
val checker = object : WatchDirectoryNotifier {
|
val checker = object : WatchDirectoryNotifier {
|
||||||
override fun shouldKeepLooping(): Boolean {
|
override fun shouldKeepLooping(): Boolean {
|
||||||
return isActive
|
return isActive
|
||||||
@ -41,12 +48,19 @@ class FileChangesWatcher @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val areAllPathsIgnored = paths.all { path ->
|
val areAllPathsIgnored = paths.all { path ->
|
||||||
ignoreRules.any { rule ->
|
val matchesAnyRule = ignoreRules.any { rule ->
|
||||||
rule.isMatch(path, Files.isDirectory(Paths.get(path)))
|
rule.isMatch(path, Files.isDirectory(Paths.get(path)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val isGitIgnoredFile = gitDirIgnoredFiles.any { ignoredFile ->
|
||||||
|
"$pathStr/.git/$ignoredFile" == path
|
||||||
|
}
|
||||||
|
|
||||||
|
matchesAnyRule || isGitIgnoredFile
|
||||||
}
|
}
|
||||||
|
|
||||||
val hasGitDirChanged = paths.any { it == "$pathStr$systemSeparator.git" }
|
|
||||||
|
val hasGitDirChanged = paths.any { it.startsWith("$pathStr$systemSeparator.git%$systemSeparator") }
|
||||||
|
|
||||||
if (!areAllPathsIgnored) {
|
if (!areAllPathsIgnored) {
|
||||||
_changesNotifier.emit(hasGitDirChanged)
|
_changesNotifier.emit(hasGitDirChanged)
|
||||||
|
@ -279,11 +279,11 @@ class TabViewModel @Inject constructor(
|
|||||||
|
|
||||||
suspend fun updateApp(hasGitDirChanged: Boolean) {
|
suspend fun updateApp(hasGitDirChanged: Boolean) {
|
||||||
if (hasGitDirChanged) {
|
if (hasGitDirChanged) {
|
||||||
printDebug(TAG, "Changes detected in git directory, full refresh")
|
printLog(TAG, "Changes detected in git directory, full refresh")
|
||||||
|
|
||||||
refreshRepositoryInfo()
|
refreshRepositoryInfo()
|
||||||
} else {
|
} else {
|
||||||
printDebug(TAG, "Changes detected, partial refresh")
|
printLog(TAG, "Changes detected, partial refresh")
|
||||||
|
|
||||||
checkUncommitedChanges()
|
checkUncommitedChanges()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user