Implemented cherry-pick
This commit is contained in:
parent
cb609c44cc
commit
72e77f41fd
@ -6,6 +6,7 @@ import org.eclipse.jgit.api.Git
|
||||
import org.eclipse.jgit.api.MergeCommand
|
||||
import org.eclipse.jgit.api.ResetCommand
|
||||
import org.eclipse.jgit.lib.Ref
|
||||
import org.eclipse.jgit.revwalk.RevCommit
|
||||
import javax.inject.Inject
|
||||
|
||||
class MergeManager @Inject constructor() {
|
||||
@ -28,4 +29,10 @@ class MergeManager @Inject constructor() {
|
||||
|
||||
git.reset().setMode(ResetCommand.ResetType.HARD).call()
|
||||
}
|
||||
|
||||
suspend fun cherryPickCommit(git: Git, revCommit: RevCommit) = withContext(Dispatchers.IO) {
|
||||
git.cherryPick()
|
||||
.include(revCommit)
|
||||
.call()
|
||||
}
|
||||
}
|
@ -370,6 +370,10 @@ fun CommitLine(
|
||||
label = "Revert commit",
|
||||
onClick = { logViewModel.revertCommit(graphNode) }
|
||||
),
|
||||
ContextMenuItem(
|
||||
label = "Cherry-pick commit",
|
||||
onClick = { logViewModel.cherrypickCommit(graphNode) }
|
||||
),
|
||||
|
||||
ContextMenuItem(
|
||||
label = "Reset current branch to this commit",
|
||||
|
@ -56,6 +56,11 @@ class LogViewModel @Inject constructor(
|
||||
branchesManager.checkoutRef(git, ref)
|
||||
}
|
||||
|
||||
fun cherrypickCommit(revCommit: RevCommit) = tabState.safeProcessing (
|
||||
refreshType = RefreshType.ONLY_LOG,
|
||||
) { git ->
|
||||
mergeManager.cherryPickCommit(git, revCommit)
|
||||
}
|
||||
|
||||
fun createBranchOnCommit(branch: String, revCommit: RevCommit) = tabState.safeProcessing(
|
||||
refreshType = RefreshType.ALL_DATA,
|
||||
|
Loading…
Reference in New Issue
Block a user