IJPL-216405 IJ-MR-181153 Terminal completion for git branches doesn't work

GitOrigin-RevId: 9bf99f986a243f837483bdf237344f55de06c7d8
This commit is contained in:
Vladimir Krivosheev
2025-11-04 10:15:17 +00:00
committed by intellij-monorepo-bot
parent d41e11d9c0
commit 2f03cadb84
20 changed files with 159 additions and 26 deletions
+2
View File
@@ -1528,8 +1528,10 @@
<module fileurl="file://$PROJECT_DIR$/plugins/git4idea/intellij.vcs.git.coverage/intellij.vcs.git.coverage.iml" filepath="$PROJECT_DIR$/plugins/git4idea/intellij.vcs.git.coverage/intellij.vcs.git.coverage.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/git-features-trainer/intellij.vcs.git.featuresTrainer.iml" filepath="$PROJECT_DIR$/plugins/git-features-trainer/intellij.vcs.git.featuresTrainer.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/git4idea/frontend/intellij.vcs.git.frontend.iml" filepath="$PROJECT_DIR$/plugins/git4idea/frontend/intellij.vcs.git.frontend.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/git4idea/localHistory/intellij.vcs.git.localHistory.iml" filepath="$PROJECT_DIR$/plugins/git4idea/localHistory/intellij.vcs.git.localHistory.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/git4idea/rt/intellij.vcs.git.rt.iml" filepath="$PROJECT_DIR$/plugins/git4idea/rt/intellij.vcs.git.rt.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/git4idea/shared/intellij.vcs.git.shared.iml" filepath="$PROJECT_DIR$/plugins/git4idea/shared/intellij.vcs.git.shared.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/git4idea/terminal/intellij.vcs.git.terminal.iml" filepath="$PROJECT_DIR$/plugins/git4idea/terminal/intellij.vcs.git.terminal.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/github/github-core/intellij.vcs.github.iml" filepath="$PROJECT_DIR$/plugins/github/github-core/intellij.vcs.github.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/github/github-git/intellij.vcs.github.git.iml" filepath="$PROJECT_DIR$/plugins/github/github-git/intellij.vcs.github.git.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/github/github-json/intellij.vcs.github.json.iml" filepath="$PROJECT_DIR$/plugins/github/github-json/intellij.vcs.github.json.iml" />
+2
View File
@@ -560,6 +560,8 @@ jvm_library(
"//tools/intellij.tools.ide.starter.junit5:ide-starter-junit5",
"//tools/intellij.tools.ide.starter.junit5:ide-starter-junit5_test_lib",
"//plugins/terminal/tests:tests_test_lib",
"//plugins/git4idea/terminal",
"//plugins/git4idea/terminal:terminal_test_lib",
]
)
### auto-generated section `build intellij.idea.community.main` end
+2
View File
@@ -928,8 +928,10 @@ plugins/git-modal-commit
plugins/git4idea
plugins/git4idea/frontend
plugins/git4idea/intellij.vcs.git.coverage
plugins/git4idea/localHistory
plugins/git4idea/rt
plugins/git4idea/shared
plugins/git4idea/terminal
plugins/github/github-core
plugins/github/github-git
plugins/github/github-json
+1
View File
@@ -257,5 +257,6 @@
<orderEntry type="module" module-name="intellij.python.processOutput" scope="TEST" />
<orderEntry type="module" module-name="intellij.tools.ide.starter.junit5" scope="TEST" />
<orderEntry type="module" module-name="intellij.terminal.tests" scope="TEST" />
<orderEntry type="module" module-name="intellij.vcs.git.terminal" scope="TEST" />
</component>
</module>
-5
View File
@@ -97,8 +97,6 @@ jvm_library(
"//plugins/performanceTesting/core:performanceTesting",
"//platform/backend/observation",
"//platform/util/coroutines",
"//plugins/terminal",
"//plugins/terminal/completion",
"//libraries/http-client",
"//platform/platform-impl/ui",
"//platform/dvcs-impl/shared",
@@ -212,9 +210,6 @@ jvm_library(
"//platform/backend/observation",
"//platform/backend/observation:observation_test_lib",
"//platform/util/coroutines",
"//plugins/terminal",
"//plugins/terminal/completion",
"//plugins/terminal/completion:completion_test_lib",
"//libraries/http-client",
"//platform/platform-impl/ui",
"//platform/dvcs-impl/shared",
-2
View File
@@ -113,8 +113,6 @@
<orderEntry type="module" module-name="intellij.performanceTesting" />
<orderEntry type="module" module-name="intellij.platform.backend.observation" />
<orderEntry type="module" module-name="intellij.platform.util.coroutines" />
<orderEntry type="module" module-name="intellij.terminal" />
<orderEntry type="module" module-name="intellij.terminal.completion" />
<orderEntry type="module" module-name="intellij.libraries.http.client" />
<orderEntry type="module" module-name="intellij.platform.ide.ui" />
<orderEntry type="module" module-name="intellij.platform.vcs.dvcs.impl.shared" />
+16
View File
@@ -0,0 +1,16 @@
### auto-generated section `build intellij.vcs.git.localHistory` start
load("@rules_jvm//:jvm.bzl", "jvm_library", "resourcegroup")
resourcegroup(
name = "localHistory_resources",
srcs = glob(["resources/**/*"]),
strip_prefix = "resources"
)
jvm_library(
name = "localHistory",
visibility = ["//visibility:public"],
srcs = glob([], allow_empty = True),
resources = [":localHistory_resources"]
)
### auto-generated section `build intellij.vcs.git.localHistory` end
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
+6
View File
@@ -7,6 +7,12 @@
- name: lib/modules/intellij.vcs.git.frontend.jar
contentModules:
- name: intellij.vcs.git.frontend
- name: lib/modules/intellij.vcs.git.localHistory.jar
contentModules:
- name: intellij.vcs.git.localHistory
- name: lib/modules/intellij.vcs.git.terminal.jar
contentModules:
- name: intellij.vcs.git.terminal
- name: lib/vcs-git-frontend.jar
contentModules:
- name: intellij.vcs.git.shared
@@ -20,8 +20,8 @@
<xi:include href="intellij.vcs.git.xml"/>
<content namespace="jetbrains">
<module name="intellij.vcs.git/localHistory"/>
<module name="intellij.vcs.git/terminal"/>
<module name="intellij.vcs.git.localHistory"/>
<module name="intellij.vcs.git.terminal"/>
<module name="intellij.vcs.git.coverage"/>
<!--It makes sense to reconsider this dependency in the future
by moving intellij.vcs.git to intellij.vcs.git.backend and making content of this module shared-->
+69
View File
@@ -0,0 +1,69 @@
### auto-generated section `build intellij.vcs.git.terminal` start
load("@rules_jvm//:jvm.bzl", "jvm_library", "resourcegroup")
resourcegroup(
name = "terminal_resources",
srcs = glob(["resources/**/*"]),
strip_prefix = "resources"
)
jvm_library(
name = "terminal",
module_name = "intellij.vcs.git.terminal",
visibility = ["//visibility:public"],
srcs = glob(["src/**/*.kt", "src/**/*.java", "src/**/*.form"], allow_empty = True),
resources = [":terminal_resources"],
deps = [
"//platform/ide-core",
"//platform/util",
"//platform/util:util-ui",
"//plugins/git4idea/shared",
"//plugins/terminal",
"//plugins/git4idea:vcs-git",
"//plugins/terminal/completion",
"//platform/core-api:core",
"//platform/dvcs-impl:vcs-dvcs-impl",
"@lib//:kotlin-stdlib",
"@lib//:jetbrains-annotations",
]
)
jvm_library(
name = "terminal_test_lib",
visibility = ["//visibility:public"],
srcs = glob(["testSrc/**/*.kt", "testSrc/**/*.java", "testSrc/**/*.form"], allow_empty = True),
associates = [":terminal"],
deps = [
"//platform/ide-core",
"//platform/util",
"//platform/util:util-ui",
"//plugins/git4idea/shared",
"//plugins/terminal",
"//plugins/git4idea:vcs-git",
"//plugins/git4idea:vcs-git_test_lib",
"//plugins/terminal/completion",
"//plugins/terminal/completion:completion_test_lib",
"//platform/core-api:core",
"//platform/dvcs-impl:vcs-dvcs-impl",
"//platform/dvcs-impl:vcs-dvcs-impl_test_lib",
"@lib//:kotlin-stdlib",
"@lib//:jetbrains-annotations",
"@lib//:junit5",
"//platform/testFramework",
"//platform/testFramework:testFramework_test_lib",
"//platform/vcs-impl/shared",
"//platform/vcs-api/shared",
"@lib//:assert_j",
"//libraries/mockito",
]
)
### auto-generated section `build intellij.vcs.git.terminal` end
### auto-generated section `test intellij.vcs.git.terminal` start
load("@community//build:tests-options.bzl", "jps_test")
jps_test(
name = "terminal_test",
runtime_deps = [":terminal_test_lib"]
)
### auto-generated section `test intellij.vcs.git.terminal` end
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/testSrc" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="intellij.platform.ide.core" />
<orderEntry type="module" module-name="intellij.platform.util" />
<orderEntry type="module" module-name="intellij.platform.util.ui" />
<orderEntry type="module" module-name="intellij.vcs.git.shared" />
<orderEntry type="module" module-name="intellij.terminal" />
<orderEntry type="module" module-name="intellij.vcs.git" />
<orderEntry type="module" module-name="intellij.terminal.completion" />
<orderEntry type="module" module-name="intellij.platform.core" />
<orderEntry type="module" module-name="intellij.platform.vcs.dvcs.impl" />
<orderEntry type="library" name="kotlin-stdlib" level="project" />
<orderEntry type="library" name="jetbrains-annotations" level="project" />
<orderEntry type="library" scope="TEST" name="JUnit5" level="project" />
<orderEntry type="module" module-name="intellij.platform.testFramework" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.vcs.impl.shared" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.vcs.shared" scope="TEST" />
<orderEntry type="library" scope="TEST" name="assertJ" level="project" />
<orderEntry type="module" module-name="intellij.libraries.mockito" scope="TEST" />
</component>
</module>
@@ -4,6 +4,6 @@
</dependencies>
<extensions defaultExtensionNs="org.jetbrains.plugins.terminal">
<commandSpecsProvider implementation="git4idea.terminal.GitCommandSpecsProvider"/>
<commandSpecsProvider implementation="com.intellij.vcs.git.terminal.GitCommandSpecsProvider"/>
</extensions>
</idea-plugin>
@@ -1,5 +1,5 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package git4idea.terminal
// 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.terminal
import com.intellij.terminal.completion.spec.ShellAliasSuggestion
import com.intellij.terminal.completion.spec.ShellRuntimeDataGenerator
@@ -1,11 +1,11 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package git4idea.terminal
// 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.terminal
import org.jetbrains.plugins.terminal.block.completion.spec.ShellCommandSpecConflictStrategy
import org.jetbrains.plugins.terminal.block.completion.spec.ShellCommandSpecInfo
import org.jetbrains.plugins.terminal.block.completion.spec.ShellCommandSpecsProvider
internal class GitCommandSpecsProvider : ShellCommandSpecsProvider {
private class GitCommandSpecsProvider : ShellCommandSpecsProvider {
override fun getCommandSpecs(): List<ShellCommandSpecInfo> = listOf(
ShellCommandSpecInfo.create(gitOverrideSpec, ShellCommandSpecConflictStrategy.OVERRIDE)
)
@@ -1,5 +1,5 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package git4idea.terminal
// 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.terminal
import com.intellij.icons.AllIcons
import com.intellij.openapi.vcs.LocalFilePath
@@ -22,8 +22,7 @@ internal const val GET_LOCAL_BRANCHES_COMMAND = "$GET_ALL_BRANCHES_COMMAND \"ref
internal const val GET_REMOTE_BRANCHES_COMMAND = "$GET_ALL_BRANCHES_COMMAND \"refs/remotes/**\""
internal val ShellRuntimeContext.repository: GitRepository?
get() = GitUtil.getRepositoryManager(project)
.getRepositoryForFileQuick(LocalFilePath(currentDirectory, true))
get() = GitUtil.getRepositoryManager(project).getRepositoryForFileQuick(LocalFilePath(currentDirectory, true))
// Find remote generators in the git.json file by searching for scripts doing:
// remote -v
@@ -1,12 +1,12 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package git4idea.terminal
// 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.terminal
import com.intellij.DynamicBundle
import org.jetbrains.annotations.Nls
import org.jetbrains.annotations.NonNls
import org.jetbrains.annotations.PropertyKey
object GitTerminalBundle {
internal object GitTerminalBundle {
@NonNls
const val BUNDLE: String = "messages.GitTerminalBundle"
private val INSTANCE = DynamicBundle(GitTerminalBundle::class.java, BUNDLE)
@@ -1,6 +1,7 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package git4idea.terminal
import com.intellij.vcs.git.terminal.parseGitAlias
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
@@ -1,10 +1,11 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package git4idea.terminal
import com.intellij.openapi.vcs.FilePath
import com.intellij.terminal.completion.spec.ShellCommandResult
import com.intellij.testFramework.fixtures.BasePlatformTestCase
import com.intellij.testFramework.replaceService
import com.intellij.vcs.git.terminal.*
import com.intellij.vcs.log.Hash
import com.intellij.vcs.log.impl.HashImpl
import git4idea.GitBranch
@@ -241,8 +242,8 @@ class GitShellCommandOverrideSpecTest : BasePlatformTestCase() {
private fun GitBranch.toCommandResult(currentBranch: GitLocalBranch): String =
when (this) {
is GitRemoteBranch -> "remotes/${name}$COLUMN_SPLIT_CHARACTER"
is GitLocalBranch -> "heads/${name}$COLUMN_SPLIT_CHARACTER" + if (this == currentBranch) "*" else ""
is GitRemoteBranch -> "remotes/${name}${COLUMN_SPLIT_CHARACTER}"
is GitLocalBranch -> "heads/${name}${COLUMN_SPLIT_CHARACTER}" + if (this == currentBranch) "*" else ""
else -> error("unknown branch type: $this")
}