дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 09:11:10 +02:00
fix(vcs): dim Git log metadata columns only for merge commits (#7119)
The User, Date and Hash cells in the Git log always used the muted color, while the subject is only dimmed for merge commits (Highlight > Merge Commits) and for commits outside the cherry-pick selection. The metadata cells now use the same condition, so a row is dimmed as a whole or not at all. My Commits still shows the author in bold. Fixes #7112
Цей коміт міститься в:
1 джерело
f3874b9b2e
коміт
5b99b8b5ab
2 files changed
+92
-1
No files matched your search
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* Git log row colors: User, Date and Hash use the normal text color on a regular
|
||||
* commit, and are dimmed together with the subject on a merge commit.
|
||||
*/
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
test("dims the metadata columns only on merge commits", async ({ workbench: page }) => {
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async () => {
|
||||
const root = "/dev/acme-api";
|
||||
const id = (i: number) => i.toString(16).padStart(40, "0");
|
||||
const commit = (i: number, parents: number[], summary: string) => ({
|
||||
id: id(i),
|
||||
shortId: id(i).slice(-8),
|
||||
parents: parents.map(id),
|
||||
refs: i === 0 ? ["HEAD", "main"] : [],
|
||||
author: `Author ${i}`,
|
||||
email: "[email protected]",
|
||||
timeMs: 1_700_000_000_000 - i * 60_000,
|
||||
summary,
|
||||
message: summary,
|
||||
});
|
||||
const commits = [
|
||||
commit(0, [1, 2], "Merge branch 'feature'"),
|
||||
commit(1, [3], "Regular change"),
|
||||
commit(2, [3], "Feature change"),
|
||||
commit(3, [], "Initial"),
|
||||
];
|
||||
const h = window.__ipc.handlers;
|
||||
h.vcs_log = ({ query }) => {
|
||||
const { skip, limit, range } = query as { skip: number; limit: number; range?: string };
|
||||
return range ? [] : commits.slice(skip, limit ? skip + limit : undefined);
|
||||
};
|
||||
h.vcs_log_refs = () => ({});
|
||||
h.vcs_branches = () => [];
|
||||
h.vcs_branch_info = () => ({
|
||||
head: "main",
|
||||
headCommit: id(0),
|
||||
upstream: null,
|
||||
ahead: 0,
|
||||
behind: 0,
|
||||
operation: null,
|
||||
});
|
||||
h.vcs_config_get = () => null;
|
||||
h.vcs_commit_files = () => [];
|
||||
h.vcs_log_details_batch = ({ revisions }) =>
|
||||
(revisions as string[]).map(() => ({
|
||||
message: "",
|
||||
containingBranches: [],
|
||||
signature: "N",
|
||||
signer: "",
|
||||
key: "",
|
||||
fingerprint: "",
|
||||
}));
|
||||
const storeModule = "/src/features/vcs/store.ts";
|
||||
const { useVcs } = await import(/* @vite-ignore */ storeModule);
|
||||
useVcs.setState({ available: true, root, repo: root, roots: [root], branchesLoaded: true });
|
||||
const contextModule = "/src/platform/context.ts";
|
||||
const { setContext } = await import(/* @vite-ignore */ contextModule);
|
||||
setContext("vcsAvailable", true);
|
||||
const optionsModule = "/src/features/vcs/logOptions.ts";
|
||||
const { useLogOptions } = await import(/* @vite-ignore */ optionsModule);
|
||||
useLogOptions.setState({ showHash: true, highlightMerges: true });
|
||||
const actionsModule = "/src/platform/actions.ts";
|
||||
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
|
||||
await executeAction("vcs.showLog");
|
||||
});
|
||||
const list = page.getByRole("listbox", { name: "Commits" });
|
||||
await expect(list.getByRole("option")).toHaveCount(4);
|
||||
|
||||
const colors = (summary: string) =>
|
||||
list
|
||||
.getByRole("option")
|
||||
.filter({ hasText: summary })
|
||||
.evaluate((row) => {
|
||||
const color = (el: Element | null) => (el ? getComputedStyle(el).color : null);
|
||||
const subject = row.querySelector("[class*=subjectText]");
|
||||
const author = row.querySelector('[title^="Author "]');
|
||||
const hash = [...row.querySelectorAll("span")].find((s) => /^0+[0-9a-f]$/.test(s.textContent ?? ""));
|
||||
return { subject: color(subject), author: color(author), hash: color(hash ?? null) };
|
||||
});
|
||||
|
||||
const regular = await colors("Regular change");
|
||||
const merge = await colors("Merge branch 'feature'");
|
||||
expect(regular.author).toBe(regular.subject);
|
||||
expect(regular.hash).toBe(regular.subject);
|
||||
expect(merge.author).toBe(merge.subject);
|
||||
expect(merge.hash).toBe(merge.subject);
|
||||
expect(merge.author).not.toBe(regular.author);
|
||||
});
|
||||
@@ -217,7 +217,8 @@ function CommitRowView({
|
||||
key={cid}
|
||||
className={clsx(
|
||||
styles.columnCell,
|
||||
styles.muted,
|
||||
// Dimmed with the subject: merge commits and commits outside the cherry-pick selection.
|
||||
(merge || outsideUnpicked) && styles.muted,
|
||||
column.id === "author" && mine && styles.mine,
|
||||
column.id === "hash" && styles.hash,
|
||||
)}
|
||||
|
||||
Reference in new issue
Заблокувати користувача