Implemented rebase interactive resuming
This commit is contained in:
parent
6501a9c98e
commit
0186a3ac90
@ -61,6 +61,17 @@ class RebaseManager @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun resumeRebase(git: Git, interactiveHandler: InteractiveHandler) = withContext(Dispatchers.IO) {
|
||||
val rebaseResult = git.rebase()
|
||||
.runInteractively(interactiveHandler)
|
||||
.setOperation(RebaseCommand.Operation.PROCESS_STEPS)
|
||||
.call()
|
||||
|
||||
if (rebaseResult.status == RebaseResult.Status.FAILED) {
|
||||
throw UncommitedChangesDetectedException("Rebase interactive failed.")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun rebaseLinesFullMessage(
|
||||
git: Git,
|
||||
rebaseTodoLines: List<RebaseTodoLine>,
|
||||
|
@ -4,8 +4,10 @@ package app.ui
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.Button
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.material.TextButton
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
@ -84,11 +86,8 @@ fun RepositoryOpenPage(tabViewModel: TabViewModel) {
|
||||
if (repositoryState == RepositoryState.REBASING_INTERACTIVE) {
|
||||
val rebaseInteractiveViewModel = tabViewModel.rebaseInteractiveViewModel
|
||||
|
||||
// TODO Implement continue rebase interactive when gitnuro has been closed
|
||||
if (rebaseInteractiveViewModel != null) {
|
||||
RebaseInteractive(rebaseInteractiveViewModel)
|
||||
} else {
|
||||
Text("Rebase started externally", color = MaterialTheme.colors.primaryTextColor)
|
||||
}
|
||||
} else {
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
|
@ -81,7 +81,7 @@ class RebaseInteractiveViewModel @Inject constructor(
|
||||
rebaseManager.rebaseInteractive(git, interactiveHandler, revCommit)
|
||||
completed = true
|
||||
} catch (ex: Exception) {
|
||||
if(ex is RebaseCancelledException) {
|
||||
if (ex is RebaseCancelledException) {
|
||||
println("Rebase cancelled")
|
||||
} else {
|
||||
cancel()
|
||||
@ -133,7 +133,7 @@ class RebaseInteractiveViewModel @Inject constructor(
|
||||
fun cancel() = tabState.runOperation(
|
||||
refreshType = RefreshType.REPO_STATE
|
||||
) { git ->
|
||||
if(!cancelled && !completed) {
|
||||
if (!cancelled && !completed) {
|
||||
rebaseManager.abortRebase(git)
|
||||
|
||||
cancelled = true
|
||||
@ -141,6 +141,23 @@ class RebaseInteractiveViewModel @Inject constructor(
|
||||
rebaseInteractiveMutex.unlock()
|
||||
}
|
||||
}
|
||||
|
||||
fun resumeRebase() = tabState.runOperation(
|
||||
showError = true,
|
||||
refreshType = RefreshType.NONE,
|
||||
) { git ->
|
||||
try {
|
||||
rebaseManager.resumeRebase(git, interactiveHandler)
|
||||
completed = true
|
||||
} catch (ex: Exception) {
|
||||
if (ex is RebaseCancelledException) {
|
||||
println("Rebase cancelled")
|
||||
} else {
|
||||
cancel()
|
||||
throw ex
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -195,6 +195,11 @@ class TabViewModel @Inject constructor(
|
||||
loadAuthorInfo(git)
|
||||
|
||||
onRepositoryStateChanged(newRepoState)
|
||||
|
||||
if (newRepoState == RepositoryState.REBASING_INTERACTIVE && rebaseInteractiveViewModel == null) {
|
||||
rebaseInteractiveViewModel = rebaseInteractiveViewModelProvider.get()
|
||||
rebaseInteractiveViewModel?.resumeRebase()
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadAuthorInfo(git: Git) {
|
||||
|
Loading…
Reference in New Issue
Block a user