mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Let reword the latest commit during rebase
Rebase during rebase is not possible, but the latest commit is reworded via amend, therefore can be allowed.
This commit is contained in:
@@ -137,10 +137,11 @@ abstract class GitCommitEditingAction : DumbAwareAction() {
|
||||
private fun commitPushedToProtectedBranchError(protectedBranch: String)
|
||||
= "The commit is already pushed to protected branch '$protectedBranch'"
|
||||
|
||||
protected fun prohibitRebaseDuringRebase(e: AnActionEvent, operation: String) {
|
||||
protected fun prohibitRebaseDuringRebase(e: AnActionEvent, operation: String, allowRebaseIfHeadCommit: Boolean = false) {
|
||||
if (e.presentation.isEnabledAndVisible) {
|
||||
val state = getRepository(e).state
|
||||
if (state == NORMAL || state == DETACHED) return
|
||||
if (state == REBASING && allowRebaseIfHeadCommit && isHeadCommit(e)) return
|
||||
|
||||
e.presentation.isEnabled = false
|
||||
e.presentation.description = when (state) {
|
||||
@@ -153,4 +154,8 @@ abstract class GitCommitEditingAction : DumbAwareAction() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected fun isHeadCommit(e: AnActionEvent): Boolean {
|
||||
return getSelectedCommit(e).id.asString() == getRepository(e).currentRevision
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class GitRewordAction : GitCommitEditingAction() {
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
super.update(e)
|
||||
prohibitRebaseDuringRebase(e, "reword")
|
||||
prohibitRebaseDuringRebase(e, "reword", true)
|
||||
}
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
|
||||
Reference in New Issue
Block a user