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:
Kirill Likhodedov
2017-08-29 22:24:23 +03:00
parent fc79462629
commit dfa6a7263c
2 changed files with 7 additions and 2 deletions
@@ -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) {