diff --git a/src/main/kotlin/app/git/RebaseManager.kt b/src/main/kotlin/app/git/RebaseManager.kt index d544656..1020415 100644 --- a/src/main/kotlin/app/git/RebaseManager.kt +++ b/src/main/kotlin/app/git/RebaseManager.kt @@ -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, diff --git a/src/main/kotlin/app/ui/RepositoryOpen.kt b/src/main/kotlin/app/ui/RepositoryOpen.kt index 012837d..f887ecf 100644 --- a/src/main/kotlin/app/ui/RepositoryOpen.kt +++ b/src/main/kotlin/app/ui/RepositoryOpen.kt @@ -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)) { diff --git a/src/main/kotlin/app/viewmodels/RebaseInteractiveViewModel.kt b/src/main/kotlin/app/viewmodels/RebaseInteractiveViewModel.kt index ba63bee..37034ea 100644 --- a/src/main/kotlin/app/viewmodels/RebaseInteractiveViewModel.kt +++ b/src/main/kotlin/app/viewmodels/RebaseInteractiveViewModel.kt @@ -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 + } + } + } } diff --git a/src/main/kotlin/app/viewmodels/TabViewModel.kt b/src/main/kotlin/app/viewmodels/TabViewModel.kt index 85148ca..0db4c5d 100644 --- a/src/main/kotlin/app/viewmodels/TabViewModel.kt +++ b/src/main/kotlin/app/viewmodels/TabViewModel.kt @@ -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) {