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) => {
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 matchesAnyRule = ignoreRules.any { rule ->
val matchesAnyIgnoreRule = ignoreRules.any { rule ->
rule.isMatch(path, Files.isDirectory(Paths.get(path)))
}
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) {
_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) {
printLog(TAG, "Changes detected in git directory, full refresh")