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(
|
suspend fun rebaseLinesFullMessage(
|
||||||
git: Git,
|
git: Git,
|
||||||
rebaseTodoLines: List<RebaseTodoLine>,
|
rebaseTodoLines: List<RebaseTodoLine>,
|
||||||
|
@ -4,8 +4,10 @@ package app.ui
|
|||||||
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
|
import androidx.compose.material.Button
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material.MaterialTheme
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
|
import androidx.compose.material.TextButton
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
@ -84,11 +86,8 @@ fun RepositoryOpenPage(tabViewModel: TabViewModel) {
|
|||||||
if (repositoryState == RepositoryState.REBASING_INTERACTIVE) {
|
if (repositoryState == RepositoryState.REBASING_INTERACTIVE) {
|
||||||
val rebaseInteractiveViewModel = tabViewModel.rebaseInteractiveViewModel
|
val rebaseInteractiveViewModel = tabViewModel.rebaseInteractiveViewModel
|
||||||
|
|
||||||
// TODO Implement continue rebase interactive when gitnuro has been closed
|
|
||||||
if (rebaseInteractiveViewModel != null) {
|
if (rebaseInteractiveViewModel != null) {
|
||||||
RebaseInteractive(rebaseInteractiveViewModel)
|
RebaseInteractive(rebaseInteractiveViewModel)
|
||||||
} else {
|
|
||||||
Text("Rebase started externally", color = MaterialTheme.colors.primaryTextColor)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
|
@ -81,7 +81,7 @@ class RebaseInteractiveViewModel @Inject constructor(
|
|||||||
rebaseManager.rebaseInteractive(git, interactiveHandler, revCommit)
|
rebaseManager.rebaseInteractive(git, interactiveHandler, revCommit)
|
||||||
completed = true
|
completed = true
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
if(ex is RebaseCancelledException) {
|
if (ex is RebaseCancelledException) {
|
||||||
println("Rebase cancelled")
|
println("Rebase cancelled")
|
||||||
} else {
|
} else {
|
||||||
cancel()
|
cancel()
|
||||||
@ -133,7 +133,7 @@ class RebaseInteractiveViewModel @Inject constructor(
|
|||||||
fun cancel() = tabState.runOperation(
|
fun cancel() = tabState.runOperation(
|
||||||
refreshType = RefreshType.REPO_STATE
|
refreshType = RefreshType.REPO_STATE
|
||||||
) { git ->
|
) { git ->
|
||||||
if(!cancelled && !completed) {
|
if (!cancelled && !completed) {
|
||||||
rebaseManager.abortRebase(git)
|
rebaseManager.abortRebase(git)
|
||||||
|
|
||||||
cancelled = true
|
cancelled = true
|
||||||
@ -141,6 +141,23 @@ class RebaseInteractiveViewModel @Inject constructor(
|
|||||||
rebaseInteractiveMutex.unlock()
|
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)
|
loadAuthorInfo(git)
|
||||||
|
|
||||||
onRepositoryStateChanged(newRepoState)
|
onRepositoryStateChanged(newRepoState)
|
||||||
|
|
||||||
|
if (newRepoState == RepositoryState.REBASING_INTERACTIVE && rebaseInteractiveViewModel == null) {
|
||||||
|
rebaseInteractiveViewModel = rebaseInteractiveViewModelProvider.get()
|
||||||
|
rebaseInteractiveViewModel?.resumeRebase()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadAuthorInfo(git: Git) {
|
private fun loadAuthorInfo(git: Git) {
|
||||||
|
Loading…
Reference in New Issue
Block a user