[vcs] IJPL-213061 Log: Add "Checkout & Update" action to the branch submenu

IJ-MR-179021

GitOrigin-RevId: cd2de17e8756da85ae6bc9beb1c091a2025dd6bc
This commit is contained in:
Aleksandr Krasilnikov
2025-10-20 19:40:11 +00:00
committed by intellij-monorepo-bot
parent 7cb0be8f15
commit b1556fe938
5 changed files with 18 additions and 5 deletions
+1
View File
@@ -2,6 +2,7 @@ f:com.intellij.vcs.git.GitDisplayName
- sf:INSTANCE:com.intellij.vcs.git.GitDisplayName
- sf:NAME:java.lang.String
- sf:POINTER:java.util.function.Supplier
com.intellij.vcs.git.actions.branch.GitBranchActionToBeWrapped
f:com.intellij.vcs.git.ref.GitRefUtil
- sf:INSTANCE:com.intellij.vcs.git.ref.GitRefUtil
- f:getCommonCurrentBranch(java.util.Collection):git4idea.GitStandardLocalBranch
@@ -0,0 +1,8 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.vcs.git.actions.branch
/**
* A marker interface for branch actions placed in "Git.Branch" group that are created dynamically and need to be
* wrapped in a [GitBranchActionWrapper] to provide proper data context.
*/
interface GitBranchActionToBeWrapped
@@ -15,7 +15,7 @@ import git4idea.GitStandardLocalBranch
import org.jetbrains.annotations.ApiStatus
@ApiStatus.Internal
class GitCheckoutWithUpdateAction : DumbAwareAction(), ActionRemoteBehaviorSpecification.FrontendOtherwiseBackend {
class GitCheckoutWithUpdateAction : GitBranchActionToBeWrapped, DumbAwareAction(), ActionRemoteBehaviorSpecification.FrontendOtherwiseBackend {
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT
override fun update(e: AnActionEvent) {
@@ -9,6 +9,7 @@ import com.intellij.openapi.project.DumbAwareAction
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.NlsActions
import com.intellij.vcs.git.actions.GitSingleRefActions
import com.intellij.vcs.git.actions.branch.GitBranchActionToBeWrapped
import git4idea.GitLocalBranch
import git4idea.GitReference
import git4idea.GitTag
@@ -21,7 +22,10 @@ import java.util.function.Supplier
import kotlin.reflect.KClass
import kotlin.reflect.safeCast
abstract class GitSingleRefAction<T : GitReference>(dynamicText: Supplier<@NlsActions.ActionText String>) : DumbAwareAction(dynamicText) {
abstract class GitSingleRefAction<T : GitReference>(
dynamicText: Supplier<@NlsActions.ActionText String>
) : GitBranchActionToBeWrapped, DumbAwareAction(dynamicText) {
@Suppress("UNCHECKED_CAST")
protected open val refClass: KClass<T> = GitReference::class as KClass<T>
@@ -3,13 +3,13 @@ package git4idea.ui.branch
import com.intellij.openapi.actionSystem.*
import com.intellij.vcs.git.actions.GitSingleRefActions
import com.intellij.vcs.git.actions.branch.GitBranchActionToBeWrapped
import git4idea.GitBranch
import git4idea.actions.branch.GitBranchActionsDataKeys
import git4idea.actions.ref.GitSingleRefAction
import git4idea.repo.GitRepository
internal class GitBranchActionWrapper(
action: GitSingleRefAction<*>,
action: AnAction,
private val branch: GitBranch,
private val selectedRepository: GitRepository,
private val repositories: List<GitRepository>,
@@ -45,7 +45,7 @@ internal class GitBranchActionWrapper(
repositories: List<GitRepository>,
) {
when (action) {
is GitSingleRefAction<*> -> result.add(GitBranchActionWrapper(action, branch, selectedRepository, repositories))
is GitBranchActionToBeWrapped -> result.add(GitBranchActionWrapper(action, branch, selectedRepository, repositories))
is ActionGroup -> {
action.getChildren(e).forEach {
doWrapActions(result, e, it, branch, selectedRepository, repositories)