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.
This commit is contained in:
l0ng-ai
2026-11-23 19:24:50 +08:00
committed by GitHub
parent 5c592bbc86
commit 0fdf37f1bf
4 changed files with 22 additions and 14 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ export interface ChooseRevisionOptions {
tags?: boolean;
branchesOnly?: boolean;
placeholder?: string;
repositories?: string[];
repositories?: (string | null)[];
commonOnly?: boolean;
}
@@ -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) => ({
+2 -1
View File
@@ -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` });
+11 -12
View File
@@ -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(