diff --git a/plugins/git4idea/resources/intellij.vcs.git.xml b/plugins/git4idea/resources/intellij.vcs.git.xml index af097175cfc7..7d612e1b9ede 100644 --- a/plugins/git4idea/resources/intellij.vcs.git.xml +++ b/plugins/git4idea/resources/intellij.vcs.git.xml @@ -633,8 +633,6 @@ description="GPG Agent configuration notification proposal (see git.commit.gpg.signing.enable.embedded.pinentry)"/> - @@ -830,6 +828,8 @@ + diff --git a/plugins/git4idea/src/git4idea/ui/branch/dashboard/BranchesDashboardFilteringLogic.kt b/plugins/git4idea/src/git4idea/ui/branch/dashboard/BranchesDashboardFilteringLogic.kt new file mode 100644 index 000000000000..57f44dc14108 --- /dev/null +++ b/plugins/git4idea/src/git4idea/ui/branch/dashboard/BranchesDashboardFilteringLogic.kt @@ -0,0 +1,27 @@ +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package git4idea.ui.branch.dashboard + +import org.jetbrains.annotations.ApiStatus + +/** + * Expected to be overridden only in the workspace model plugin. + */ +@ApiStatus.Internal +interface BranchesDashboardFilteringLogic { + /** + * `true` means that branches in the branch dashboard tree will be hidden for roots excluded in the root filter + */ + fun showBranchesMatchingRootFilter(): Boolean + + /** + * Defines filtering logic in case of grouping by repository is enabled. + * + * `true` means that log will be filtered by both branch name and root, `false` - only by branch name. + */ + fun filterByBranchAndRoot(): Boolean +} + +internal class DefaultBranchDashboardFilteringLogic : BranchesDashboardFilteringLogic { + override fun showBranchesMatchingRootFilter(): Boolean = true + override fun filterByBranchAndRoot(): Boolean = !showBranchesMatchingRootFilter() +} \ No newline at end of file diff --git a/plugins/git4idea/src/git4idea/ui/branch/dashboard/BranchesInGitLogUiFactoryProvider.kt b/plugins/git4idea/src/git4idea/ui/branch/dashboard/BranchesInGitLogUiFactoryProvider.kt index 069e9e2f4c5a..56bde06f5245 100644 --- a/plugins/git4idea/src/git4idea/ui/branch/dashboard/BranchesInGitLogUiFactoryProvider.kt +++ b/plugins/git4idea/src/git4idea/ui/branch/dashboard/BranchesInGitLogUiFactoryProvider.kt @@ -3,11 +3,11 @@ package git4idea.ui.branch.dashboard import com.intellij.icons.AllIcons import com.intellij.openapi.actionSystem.* +import com.intellij.openapi.components.service import com.intellij.openapi.project.Project import com.intellij.openapi.util.Comparing import com.intellij.openapi.util.Disposer import com.intellij.openapi.util.NlsActions -import com.intellij.openapi.util.registry.Registry import com.intellij.openapi.vcs.ProjectLevelVcsManager import com.intellij.openapi.vcs.VcsRoot import com.intellij.openapi.vfs.VirtualFile @@ -106,7 +106,7 @@ internal class BranchesVcsLogUi( val roots = logData.roots.toSet() val logUiFilterListener = VcsLogFilterUiEx.VcsLogFilterListener { model.rootsToFilter = when { - roots.size == 1 || BranchesDashboardBehaviour.alwaysShowBranchForAllRoots() -> roots + roots.size == 1 || !logData.project.service().showBranchesMatchingRootFilter() -> roots else -> VcsLogUtil.getAllVisibleRoots(roots, filterUi.filters) } } @@ -218,7 +218,7 @@ internal class BranchesVcsLogUi( } override fun filterBy(branches: List, repositories: Set) { - if (BranchesDashboardBehaviour.filterByBranchAndRoot() && repositories.isNotEmpty()) { + if (logData.project.service().filterByBranchAndRoot() && repositories.isNotEmpty()) { val roots = repositories.map { it.root }.takeIf { !Comparing.haveEqualElements(logData.roots, it) } filterUi.filterBy(branches, roots) } @@ -292,10 +292,4 @@ val CHANGE_LOG_FILTER_ON_BRANCH_SELECTION_PROPERTY: VcsLogUiProperties.VcsLogUiP val NAVIGATE_LOG_TO_BRANCH_ON_BRANCH_SELECTION_PROPERTY: VcsLogUiProperties.VcsLogUiProperty = object : VcsLogApplicationSettings.CustomBooleanProperty("Navigate.Log.To.Branch.on.Branch.Selection") { override fun defaultValue() = false - } - -private object BranchesDashboardBehaviour { - fun alwaysShowBranchForAllRoots(): Boolean = filterByBranchAndRoot() - - fun filterByBranchAndRoot(): Boolean = Registry.`is`("git.branch.dashboard.filter.branch.and.root") -} \ No newline at end of file + } \ No newline at end of file