Fixed repo state not refreshing if branch checkout has failed after creation
This commit is contained in:
parent
dcf9ceb6a3
commit
69089c9910
@ -55,10 +55,12 @@ class TabState @Inject constructor(
|
||||
showError: Boolean = true,
|
||||
refreshType: RefreshType,
|
||||
refreshEvenIfCrashes: Boolean = false,
|
||||
refreshEvenIfCrashesInteractive: ((Exception) -> Boolean)? = null,
|
||||
callback: suspend (git: Git) -> Unit
|
||||
) =
|
||||
scope.launch(Dispatchers.IO) {
|
||||
var hasProcessFailed = false
|
||||
var refreshEvenIfCrashesInteractiveResult = false
|
||||
operationRunning = true
|
||||
|
||||
try {
|
||||
@ -74,13 +76,15 @@ class TabState @Inject constructor(
|
||||
hasProcessFailed = true
|
||||
ex.printStackTrace()
|
||||
|
||||
refreshEvenIfCrashesInteractiveResult = refreshEvenIfCrashesInteractive?.invoke(ex) ?: false
|
||||
|
||||
if (showError)
|
||||
errorsManager.addError(newErrorNow(ex, ex.message.orEmpty()))
|
||||
} finally {
|
||||
_processing.value = false
|
||||
operationRunning = false
|
||||
|
||||
if (refreshType != RefreshType.NONE && (!hasProcessFailed || refreshEvenIfCrashes)) {
|
||||
if (refreshType != RefreshType.NONE && (!hasProcessFailed || refreshEvenIfCrashes || refreshEvenIfCrashesInteractiveResult)) {
|
||||
_refreshData.emit(refreshType)
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.launch
|
||||
import org.eclipse.jgit.api.Git
|
||||
import org.eclipse.jgit.api.errors.CheckoutConflictException
|
||||
import org.eclipse.jgit.lib.Ref
|
||||
import org.eclipse.jgit.revwalk.RevCommit
|
||||
import javax.inject.Inject
|
||||
@ -213,6 +214,7 @@ class LogViewModel @Inject constructor(
|
||||
|
||||
fun createBranchOnCommit(branch: String, revCommit: RevCommit) = tabState.safeProcessing(
|
||||
refreshType = RefreshType.ALL_DATA,
|
||||
refreshEvenIfCrashesInteractive = { it is CheckoutConflictException },
|
||||
) { git ->
|
||||
createBranchOnCommitUseCase(git, branch, revCommit)
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import org.eclipse.jgit.api.Git
|
||||
import org.eclipse.jgit.api.errors.CheckoutConflictException
|
||||
import org.eclipse.jgit.blame.BlameResult
|
||||
import org.eclipse.jgit.lib.Repository
|
||||
import org.eclipse.jgit.lib.RepositoryState
|
||||
@ -415,7 +416,7 @@ class TabViewModel @Inject constructor(
|
||||
|
||||
fun createBranch(branchName: String) = tabState.safeProcessing(
|
||||
refreshType = RefreshType.ALL_DATA,
|
||||
refreshEvenIfCrashes = true,
|
||||
refreshEvenIfCrashesInteractive = { it is CheckoutConflictException },
|
||||
) { git ->
|
||||
createBranchUseCase(git, branchName)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user