Fixed .git dir changes not being detected properly and added rule to ignore .proble files in git dir

This commit is contained in:
Abdelilah El Aissaoui 2023-09-27 12:45:48 +02:00
parent 1d40964c17
commit 7e6ccbe810
No known key found for this signature in database
GPG Key ID: 7587FC860F594869
3 changed files with 9 additions and 6 deletions

View File

@ -36,7 +36,7 @@ pub fn watch_directory(
} }
Err(e) => { Err(e) => {
if e != RecvTimeoutError::Timeout { if e != RecvTimeoutError::Timeout {
println!("Watch error: {:?}", e) println!("Watch error: {:?}", e);
} }
} }
} }

View File

@ -48,18 +48,21 @@ class FileChangesWatcher @Inject constructor(
} }
val areAllPathsIgnored = paths.all { path -> val areAllPathsIgnored = paths.all { path ->
val matchesAnyRule = ignoreRules.any { rule -> val matchesAnyIgnoreRule = ignoreRules.any { rule ->
rule.isMatch(path, Files.isDirectory(Paths.get(path))) rule.isMatch(path, Files.isDirectory(Paths.get(path)))
} }
val isGitIgnoredFile = gitDirIgnoredFiles.any { ignoredFile -> val isGitIgnoredFile = gitDirIgnoredFiles.any { ignoredFile ->
"$pathStr/.git/$ignoredFile" == path "$pathStr$systemSeparator.git$systemSeparator$ignoredFile" == path
} }
matchesAnyRule || isGitIgnoredFile // JGit may create .probe-UUID files for its internal stuff, we should not care about it
val onlyProbeFiles = paths.all { it.contains("$systemSeparator.git$systemSeparator.probe-") }
matchesAnyIgnoreRule || isGitIgnoredFile || onlyProbeFiles
} }
val hasGitDirChanged = paths.any { it.startsWith("$pathStr$systemSeparator.git%$systemSeparator") } val hasGitDirChanged = paths.any { it.startsWith("$pathStr$systemSeparator.git$systemSeparator") }
if (!areAllPathsIgnored) { if (!areAllPathsIgnored) {
_changesNotifier.emit(hasGitDirChanged) _changesNotifier.emit(hasGitDirChanged)

View File

@ -279,7 +279,7 @@ class TabViewModel @Inject constructor(
} }
} }
suspend fun updateApp(hasGitDirChanged: Boolean) { private suspend fun updateApp(hasGitDirChanged: Boolean) {
if (hasGitDirChanged) { if (hasGitDirChanged) {
printLog(TAG, "Changes detected in git directory, full refresh") printLog(TAG, "Changes detected in git directory, full refresh")