Added option to abort cherry-pick.
Uncommited changes line will be shown now even when the status is empty if the repo is rebasing, merging or cherry-picking. This will allow the user to abort the operation if required.
This commit is contained in:
parent
765d0e9d96
commit
a86d1f7c1b
@ -4,3 +4,6 @@ import org.eclipse.jgit.lib.RepositoryState
|
||||
|
||||
val RepositoryState.isMerging
|
||||
get() = this == RepositoryState.MERGING || this == RepositoryState.MERGING_RESOLVED
|
||||
|
||||
val RepositoryState.isCherryPicking
|
||||
get() = this == RepositoryState.CHERRY_PICKING || this == RepositoryState.CHERRY_PICKING_RESOLVED
|
@ -29,7 +29,7 @@ class MergeManager @Inject constructor() {
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun abortMerge(git: Git) = withContext(Dispatchers.IO) {
|
||||
suspend fun resetRepoState(git: Git) = withContext(Dispatchers.IO) {
|
||||
git.repository.writeMergeCommitMsg(null)
|
||||
git.repository.writeMergeHeads(null)
|
||||
|
||||
|
@ -194,7 +194,7 @@ fun UncommitedChanges(
|
||||
repositoryState.isMerging -> MergeButtons(
|
||||
haveConflictsBeenSolved = unstaged.isEmpty(),
|
||||
onAbort = {
|
||||
statusViewModel.abortMerge()
|
||||
statusViewModel.resetRepoState()
|
||||
statusViewModel.updateCommitMessage("")
|
||||
},
|
||||
onMerge = { doCommit(false) }
|
||||
@ -209,6 +209,16 @@ fun UncommitedChanges(
|
||||
onContinue = { statusViewModel.continueRebase() },
|
||||
onSkip = { statusViewModel.skipRebase() },
|
||||
)
|
||||
repositoryState.isCherryPicking -> CherryPickingButtons(
|
||||
haveConflictsBeenSolved = unstaged.isEmpty(),
|
||||
onAbort = {
|
||||
statusViewModel.resetRepoState()
|
||||
statusViewModel.updateCommitMessage("")
|
||||
},
|
||||
onCommit = {
|
||||
doCommit(false)
|
||||
}
|
||||
)
|
||||
else -> UncommitedChangesButtons(
|
||||
canCommit = canCommit,
|
||||
canAmend = canAmend,
|
||||
@ -310,6 +320,33 @@ fun MergeButtons(
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun CherryPickingButtons(
|
||||
haveConflictsBeenSolved: Boolean,
|
||||
onAbort: () -> Unit,
|
||||
onCommit: () -> Unit,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
AbortButton(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(end = 4.dp),
|
||||
onClick = onAbort
|
||||
)
|
||||
|
||||
ConfirmationButton(
|
||||
text = "Commit",
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(start = 4.dp),
|
||||
enabled = haveConflictsBeenSolved,
|
||||
onClick = onCommit,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun RebasingButtons(
|
||||
canContinue: Boolean,
|
||||
|
@ -333,14 +333,23 @@ fun MessagesList(
|
||||
state = scrollState,
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
) {
|
||||
if (hasUncommitedChanges) item {
|
||||
UncommitedChangesLine(graphWidth = graphWidth,
|
||||
if (
|
||||
hasUncommitedChanges ||
|
||||
repositoryState.isMerging ||
|
||||
repositoryState.isRebasing ||
|
||||
repositoryState.isCherryPicking
|
||||
) {
|
||||
item {
|
||||
UncommitedChangesLine(
|
||||
graphWidth = graphWidth,
|
||||
isSelected = selectedItem == SelectedItem.UncommitedChanges,
|
||||
statusSummary = logStatus.statusSummary,
|
||||
repositoryState = repositoryState,
|
||||
onUncommitedChangesSelected = {
|
||||
logViewModel.selectUncommitedChanges()
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
items(items = commitList) { graphNode ->
|
||||
CommitLine(
|
||||
@ -600,6 +609,7 @@ fun UncommitedChangesLine(
|
||||
val text = when {
|
||||
repositoryState.isRebasing -> "Pending changes to rebase"
|
||||
repositoryState.isMerging -> "Pending changes to merge"
|
||||
repositoryState.isCherryPicking -> "Pending changes to cherry-pick"
|
||||
else -> "Uncommited changes"
|
||||
}
|
||||
|
||||
|
@ -201,10 +201,10 @@ class StatusViewModel @Inject constructor(
|
||||
rebaseManager.skipRebase(git)
|
||||
}
|
||||
|
||||
fun abortMerge() = tabState.safeProcessing(
|
||||
fun resetRepoState() = tabState.safeProcessing(
|
||||
refreshType = RefreshType.ALL_DATA,
|
||||
) { git ->
|
||||
mergeManager.abortMerge(git)
|
||||
mergeManager.resetRepoState(git)
|
||||
}
|
||||
|
||||
fun deleteFile(statusEntry: StatusEntry) = tabState.runOperation(
|
||||
|
@ -305,6 +305,7 @@ class TabViewModel @Inject constructor(
|
||||
// Stashes list should only be updated if we are doing a stash operation, however it's a small operation
|
||||
// that we can afford to do when doing other operations
|
||||
stashesViewModel.refresh(git)
|
||||
loadRepositoryState(git)
|
||||
}
|
||||
|
||||
private suspend fun refreshRepositoryInfo() = tabState.safeProcessing(
|
||||
|
Loading…
Reference in New Issue
Block a user