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
@ -3,4 +3,7 @@ package app.extensions
|
|||||||
import org.eclipse.jgit.lib.RepositoryState
|
import org.eclipse.jgit.lib.RepositoryState
|
||||||
|
|
||||||
val RepositoryState.isMerging
|
val RepositoryState.isMerging
|
||||||
get() = this == RepositoryState.MERGING || this == RepositoryState.MERGING_RESOLVED
|
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.writeMergeCommitMsg(null)
|
||||||
git.repository.writeMergeHeads(null)
|
git.repository.writeMergeHeads(null)
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ fun UncommitedChanges(
|
|||||||
repositoryState.isMerging -> MergeButtons(
|
repositoryState.isMerging -> MergeButtons(
|
||||||
haveConflictsBeenSolved = unstaged.isEmpty(),
|
haveConflictsBeenSolved = unstaged.isEmpty(),
|
||||||
onAbort = {
|
onAbort = {
|
||||||
statusViewModel.abortMerge()
|
statusViewModel.resetRepoState()
|
||||||
statusViewModel.updateCommitMessage("")
|
statusViewModel.updateCommitMessage("")
|
||||||
},
|
},
|
||||||
onMerge = { doCommit(false) }
|
onMerge = { doCommit(false) }
|
||||||
@ -209,6 +209,16 @@ fun UncommitedChanges(
|
|||||||
onContinue = { statusViewModel.continueRebase() },
|
onContinue = { statusViewModel.continueRebase() },
|
||||||
onSkip = { statusViewModel.skipRebase() },
|
onSkip = { statusViewModel.skipRebase() },
|
||||||
)
|
)
|
||||||
|
repositoryState.isCherryPicking -> CherryPickingButtons(
|
||||||
|
haveConflictsBeenSolved = unstaged.isEmpty(),
|
||||||
|
onAbort = {
|
||||||
|
statusViewModel.resetRepoState()
|
||||||
|
statusViewModel.updateCommitMessage("")
|
||||||
|
},
|
||||||
|
onCommit = {
|
||||||
|
doCommit(false)
|
||||||
|
}
|
||||||
|
)
|
||||||
else -> UncommitedChangesButtons(
|
else -> UncommitedChangesButtons(
|
||||||
canCommit = canCommit,
|
canCommit = canCommit,
|
||||||
canAmend = canAmend,
|
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
|
@Composable
|
||||||
fun RebasingButtons(
|
fun RebasingButtons(
|
||||||
canContinue: Boolean,
|
canContinue: Boolean,
|
||||||
|
@ -333,14 +333,23 @@ fun MessagesList(
|
|||||||
state = scrollState,
|
state = scrollState,
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
) {
|
) {
|
||||||
if (hasUncommitedChanges) item {
|
if (
|
||||||
UncommitedChangesLine(graphWidth = graphWidth,
|
hasUncommitedChanges ||
|
||||||
isSelected = selectedItem == SelectedItem.UncommitedChanges,
|
repositoryState.isMerging ||
|
||||||
statusSummary = logStatus.statusSummary,
|
repositoryState.isRebasing ||
|
||||||
repositoryState = repositoryState,
|
repositoryState.isCherryPicking
|
||||||
onUncommitedChangesSelected = {
|
) {
|
||||||
logViewModel.selectUncommitedChanges()
|
item {
|
||||||
})
|
UncommitedChangesLine(
|
||||||
|
graphWidth = graphWidth,
|
||||||
|
isSelected = selectedItem == SelectedItem.UncommitedChanges,
|
||||||
|
statusSummary = logStatus.statusSummary,
|
||||||
|
repositoryState = repositoryState,
|
||||||
|
onUncommitedChangesSelected = {
|
||||||
|
logViewModel.selectUncommitedChanges()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
items(items = commitList) { graphNode ->
|
items(items = commitList) { graphNode ->
|
||||||
CommitLine(
|
CommitLine(
|
||||||
@ -600,6 +609,7 @@ fun UncommitedChangesLine(
|
|||||||
val text = when {
|
val text = when {
|
||||||
repositoryState.isRebasing -> "Pending changes to rebase"
|
repositoryState.isRebasing -> "Pending changes to rebase"
|
||||||
repositoryState.isMerging -> "Pending changes to merge"
|
repositoryState.isMerging -> "Pending changes to merge"
|
||||||
|
repositoryState.isCherryPicking -> "Pending changes to cherry-pick"
|
||||||
else -> "Uncommited changes"
|
else -> "Uncommited changes"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,10 +201,10 @@ class StatusViewModel @Inject constructor(
|
|||||||
rebaseManager.skipRebase(git)
|
rebaseManager.skipRebase(git)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun abortMerge() = tabState.safeProcessing(
|
fun resetRepoState() = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
) { git ->
|
) { git ->
|
||||||
mergeManager.abortMerge(git)
|
mergeManager.resetRepoState(git)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteFile(statusEntry: StatusEntry) = tabState.runOperation(
|
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
|
// 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
|
// that we can afford to do when doing other operations
|
||||||
stashesViewModel.refresh(git)
|
stashesViewModel.refresh(git)
|
||||||
|
loadRepositoryState(git)
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun refreshRepositoryInfo() = tabState.safeProcessing(
|
private suspend fun refreshRepositoryInfo() = tabState.safeProcessing(
|
||||||
|
Loading…
Reference in New Issue
Block a user