diff --git a/src/main/kotlin/app/git/RebaseManager.kt b/src/main/kotlin/app/git/RebaseManager.kt index d706370..bf5ab12 100644 --- a/src/main/kotlin/app/git/RebaseManager.kt +++ b/src/main/kotlin/app/git/RebaseManager.kt @@ -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( diff --git a/src/main/kotlin/app/viewmodels/RebaseInteractiveViewModel.kt b/src/main/kotlin/app/viewmodels/RebaseInteractiveViewModel.kt index 442dfca..ba63bee 100644 --- a/src/main/kotlin/app/viewmodels/RebaseInteractiveViewModel.kt +++ b/src/main/kotlin/app/viewmodels/RebaseInteractiveViewModel.kt @@ -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 + } } }