Rebase interactive is aborted when something fails during the process

This commit is contained in:
Abdelilah El Aissaoui 2022-05-27 15:52:16 +02:00
parent f124d1fb9e
commit cb3fe17fee
2 changed files with 13 additions and 3 deletions

View File

@ -50,11 +50,15 @@ class RebaseManager @Inject constructor(
suspend fun rebaseInteractive(git: Git, interactiveHandler: InteractiveHandler, commit: RevCommit) {
//TODO Check possible rebase errors by checking the result
git.rebase()
val rebaseResult = git.rebase()
.runInteractively(interactiveHandler)
.setOperation(RebaseCommand.Operation.BEGIN)
.setUpstream(commit)
.call()
if (rebaseResult.status == RebaseResult.Status.FAILED) {
throw UncommitedChangesDetectedException("Rebase interactive failed.")
}
}
suspend fun rebaseLinesFullMessage(

View File

@ -75,12 +75,18 @@ class RebaseInteractiveViewModel @Inject constructor(
suspend fun startRebaseInteractive(revCommit: RevCommit) = tabState.runOperation(
refreshType = RefreshType.ALL_DATA,
showError = true
) { git ->
try {
rebaseManager.rebaseInteractive(git, interactiveHandler, revCommit)
completed = true
} catch (ex: RebaseCancelledException) {
println("Rebase cancelled")
} catch (ex: Exception) {
if(ex is RebaseCancelledException) {
println("Rebase cancelled")
} else {
cancel()
throw ex
}
}
}