From 0fdf37f1bfb43d517739e069fa3d96aaa0c1ea70 Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Mon, 23 Nov 2026 19:24:50 +0800 Subject: [PATCH] fix(vcs): list every repository's branches and tags in Go to Hash/Branch/Tag (#5455) Go to Hash/Branch/Tag reads refs from the repositories it searches (shown log tab, else the filtered ones, else every root) instead of an empty Repository filter, which offered only HEAD. --- src/features/vcs/RevisionChooser.tsx | 2 +- src/features/vcs/__tests__/multiRoot.test.ts | 8 +++++++ src/features/vcs/historyActions.tsx | 3 ++- src/features/vcs/logStore.ts | 23 ++++++++++---------- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/features/vcs/RevisionChooser.tsx b/src/features/vcs/RevisionChooser.tsx index fd075c875..e105c0361 100644 --- a/src/features/vcs/RevisionChooser.tsx +++ b/src/features/vcs/RevisionChooser.tsx @@ -32,7 +32,7 @@ export interface ChooseRevisionOptions { tags?: boolean; branchesOnly?: boolean; placeholder?: string; - repositories?: string[]; + repositories?: (string | null)[]; commonOnly?: boolean; } diff --git a/src/features/vcs/__tests__/multiRoot.test.ts b/src/features/vcs/__tests__/multiRoot.test.ts index 6ddc637e1..270c0b919 100644 --- a/src/features/vcs/__tests__/multiRoot.test.ts +++ b/src/features/vcs/__tests__/multiRoot.test.ts @@ -17,6 +17,7 @@ import { commitKey, graphCommit, mergeRepoLogs, type RepoCommit } from "../multi import { buildRepositoryBranchTree } from "../branches"; import { emptyFilters, + goToRefRepositories, installGitLog, loadMore, openLogTab, @@ -218,6 +219,13 @@ describe("multi-root Git log", () => { expect(toggleRepository(["/project/back"], "/project/back")).toEqual([]); }); + it("offers Go to Hash/Branch/Tag every repository when the Repository filter is cleared", () => { + useGitLog.setState({ filters: { ...emptyFilters(), repositories: [] } }); + expect(goToRefRepositories()).toEqual(["/project/front", "/project/back"]); + useGitLog.setState({ filters: { ...emptyFilters(), repositories: ["/project/back"] } }); + expect(goToRefRepositories()).toEqual(["/project/back"]); + }); + it("groups identical local and remote names under distinct repository nodes", () => { const roots = buildRepositoryBranchTree( ["front", "back"].map((name) => ({ diff --git a/src/features/vcs/historyActions.tsx b/src/features/vcs/historyActions.tsx index cbd4ba501..17913da94 100644 --- a/src/features/vcs/historyActions.tsx +++ b/src/features/vcs/historyActions.tsx @@ -33,6 +33,7 @@ import { goToChild, goToParent, goToRef, + goToRefRepositories, openLogTab, selectedCommits, toggleCommitBookmark, @@ -388,7 +389,7 @@ export function registerHistoryActions(): () => void { const rev = await chooseRevision("Go to Hash/Branch/Tag", { tags: true, placeholder: "Enter hash or branch/tag name", - repositories: tab?.repo ? [tab.repo] : log.filters.repositories, + repositories: goToRefRepositories(log), }); if (rev && !(await goToRef(rev))) notifications().notify({ group: "vcs", level: "warning", title: `'${rev}' was not found in the log` }); diff --git a/src/features/vcs/logStore.ts b/src/features/vcs/logStore.ts index 36dde3a90..cf242e7d9 100644 --- a/src/features/vcs/logStore.ts +++ b/src/features/vcs/logStore.ts @@ -1395,6 +1395,16 @@ export function isMine(c: Commit, user: string | null): boolean { ); } +/** The repositories Go to Hash/Branch/Tag looks in: the shown log's, else the filtered ones, else every root. */ +export function goToRefRepositories(state: LogState = useGitLog.getState()): (string | null)[] { + const logTab = state.logTabs.find((t) => t.id === state.shownLog); + if (logTab?.repositories?.length) return logTab.repositories; + if (logTab?.repo) return [logTab.repo]; + if (state.filters.repositories?.length) return state.filters.repositories; + const roots = useVcs.getState().roots; + return roots.length ? roots : [currentRepo()]; +} + /** * Go to Hash/Branch/Tag: selects the commit `rev` names, paging the log until it is * loaded (and clearing the filters when they hide it). False when there is no such commit. @@ -1410,18 +1420,7 @@ export async function goToRef(rev: string, repository?: string | null): Promise< await load; }; const logTab = state.logTabs.find((t) => t.id === state.shownLog); - const repos = - repository !== undefined - ? [repository] - : logTab?.repositories?.length - ? logTab.repositories - : logTab?.repo - ? [logTab.repo] - : state.filters.repositories?.length - ? state.filters.repositories - : useVcs.getState().roots.length - ? useVcs.getState().roots - : [currentRepo()]; + const repos = repository !== undefined ? [repository] : goToRefRepositories(state); if (repos.length > 1) { const candidates = ( await Promise.all(