[git] Make action final when parsing rebase file

GitOrigin-RevId: fa0eb37d9ae39745193bc347a69cc1dd8a73fe78
This commit is contained in:
Ilia.Shulgin
2024-06-20 17:05:15 +02:00
committed by intellij-monorepo-bot
parent 8c7ba50c37
commit cfbbdf36fa
2 changed files with 12 additions and 10 deletions

View File

@@ -45,14 +45,12 @@ class GitInteractiveRebaseFile {
continue;
}
String command = s.spaceToken();
GitRebaseEntry.Action action = GitRebaseEntry.parseAction(command);
final GitRebaseEntry.Action action = GitRebaseEntry.parseAction(command);
String hash = s.spaceToken();
while (true) {
GitRebaseEntry.Action newAction = action.parseParameter(hash);
if (newAction == null) break;
action = newAction;
boolean paramConsumed = action.consumeParameter(hash);
if (!paramConsumed) break;
hash = s.spaceToken();
}

View File

@@ -19,12 +19,16 @@ internal open class GitRebaseEntry(val action: Action, val commit: String, val s
object DROP : KnownAction("drop", "d", nameKey = "rebase.entry.action.name.drop")
object REWORD : KnownAction("reword", "r", nameKey = "rebase.entry.action.name.reword")
object SQUASH : KnownAction("squash", "s", nameKey = "rebase.entry.action.name.squash")
class FIXUP(val overrideMessage: Boolean = false) : KnownAction("fixup", "f", nameKey = "rebase.entry.action.name.fixup") {
override fun parseParameter(parameter: String): Action? {
class FIXUP : KnownAction("fixup", "f", nameKey = "rebase.entry.action.name.fixup") {
var overrideMessage: Boolean = false
private set
override fun consumeParameter(parameter: String): Boolean {
if (!overrideMessage && parameter == "-c" || parameter == "-C") {
return FIXUP(true)
overrideMessage = true
return true
}
return null
return false
}
}
object UPDATE_REF : KnownAction("update-ref", isCommit = false, nameKey = "rebase.entry.action.name.update.ref")
@@ -33,7 +37,7 @@ internal open class GitRebaseEntry(val action: Action, val commit: String, val s
val visibleName: Supplier<@NlsContexts.Button String> get() = GitBundle.messagePointer(nameKey)
open fun parseParameter(parameter: String): Action? = null
protected open fun consumeParameter(parameter: String): Boolean = false
override fun toString(): String = command
}