mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 16:04:21 +00:00
fix(vcs): align Git Log commit message typography (#5103)
Git Log now uses the editor's configured font, size, and weights for commit subjects and descriptions. Authors, dates, branches, and signatures use smaller UI text and tighter spacing. Long metadata can wrap inside the details pane.
This commit is contained in:
@@ -60,6 +60,58 @@ test.beforeEach(async ({ workbench: page }) => {
|
||||
await expect(page.getByRole("listbox", { name: "Commits" }).getByRole("option").first()).toBeVisible();
|
||||
});
|
||||
|
||||
test("Git Log separates commit message typography from compact metadata", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 860, height: 720 });
|
||||
await page.evaluate(() => {
|
||||
window.__ipc.handlers.vcs_log_details_batch = ({ revisions }) =>
|
||||
(revisions as string[]).map(() => ({
|
||||
message: "Commit 1\n\nUpdate checkout totals after applying shipping discounts.",
|
||||
containingBranches: ["feature/update-checkout-totals-and-apply-shipping-discounts".repeat(3)],
|
||||
signature: "N",
|
||||
signer: "",
|
||||
key: "",
|
||||
fingerprint: "",
|
||||
}));
|
||||
});
|
||||
const setEditorSize = (fontSize: number) =>
|
||||
page.evaluate(async (fontSize) => {
|
||||
const module = "/src/platform/project.ts";
|
||||
const { useProject } = await import(/* @vite-ignore */ module);
|
||||
const { settings } = useProject.getState();
|
||||
useProject.setState({
|
||||
settings: { ...settings, editor: { ...settings?.editor, fontFamily: "Consolas", fontSize } },
|
||||
});
|
||||
}, fontSize);
|
||||
await setEditorSize(18);
|
||||
const commits = page.getByRole("listbox", { name: "Commits" });
|
||||
await commits.getByRole("option").filter({ hasText: "Commit 1" }).first().click();
|
||||
|
||||
const message = page.locator("#message");
|
||||
const subject = message.getByText("Commit 1", { exact: true });
|
||||
const body = message.getByText("Update checkout totals after applying shipping discounts.", { exact: true });
|
||||
await expect(body).toHaveCSS("font-size", "18px");
|
||||
await expect(body).toHaveCSS("font-family", /Consolas/);
|
||||
await expect(subject).toHaveCSS("font-size", "18px");
|
||||
const author = message.getByTitle("Copy revision number").locator("..");
|
||||
const parent = message.getByText(/^Parent\s/);
|
||||
await expect(author).toHaveCSS("font-size", "12px");
|
||||
const authorBox = (await author.boundingBox())!;
|
||||
const parentBox = (await parent.boundingBox())!;
|
||||
expect(parentBox.y - authorBox.y - authorBox.height).toBeLessThanOrEqual(4);
|
||||
const signature = message.getByText(/Signature: Unsigned/);
|
||||
await signature.scrollIntoViewIfNeeded();
|
||||
await expect(signature).toBeInViewport();
|
||||
const overflow = await message.evaluate((el) => {
|
||||
const scroller = el.querySelector('[class*="_messageBox_"]')!;
|
||||
return scroller.scrollWidth - scroller.clientWidth;
|
||||
});
|
||||
expect(overflow).toBeLessThanOrEqual(1);
|
||||
|
||||
await setEditorSize(15);
|
||||
await expect(body).toHaveCSS("font-size", "15px");
|
||||
await expect(author).toHaveCSS("font-size", "12px");
|
||||
});
|
||||
|
||||
test("a second click on a Git Log toolbar button closes its popup", async ({ workbench: page }) => {
|
||||
const toolbar = page.getByRole("toolbar", { name: "Log filters" });
|
||||
const branchPopup = page.getByRole("dialog", { name: "Filter by Branch" });
|
||||
|
||||
@@ -630,33 +630,36 @@
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.messageText {
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.subjectLine {
|
||||
color: var(--fg-strong);
|
||||
font-weight: 600;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.fullMessage {
|
||||
margin-top: 6px;
|
||||
margin-top: var(--space-1-5);
|
||||
color: var(--fg);
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.meta {
|
||||
margin-top: 10px;
|
||||
font-size: var(--fs-small);
|
||||
color: var(--fg-subtle);
|
||||
line-height: 1.5;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.messageText + .meta {
|
||||
margin-top: var(--space-2);
|
||||
}
|
||||
.meta + .meta,
|
||||
.commitEntry .messageText + .meta {
|
||||
margin-top: var(--space-0-5);
|
||||
}
|
||||
.commitEntry + .commitEntry {
|
||||
margin-top: 10px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
.metaCompact {
|
||||
margin-top: 2px;
|
||||
}
|
||||
.meta .refs {
|
||||
margin-left: 0;
|
||||
max-width: none;
|
||||
@@ -670,6 +673,10 @@
|
||||
.hash {
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
.messageText .linkButton,
|
||||
.meta .linkButton {
|
||||
max-width: 100%;
|
||||
}
|
||||
.linkButton {
|
||||
color: var(--link);
|
||||
font: inherit;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import type { Commit } from "@/bindings";
|
||||
import { writeClipboardText } from "@/platform/clipboard";
|
||||
import { fontWeightOf } from "@/platform/editorSettings";
|
||||
import { resolveMonoFont } from "@/platform/fonts";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { useProject } from "@/platform/project";
|
||||
import clsx from "clsx";
|
||||
import styles from "../GitLog.module.css";
|
||||
import { IssueText } from "../issueLinks";
|
||||
@@ -47,24 +50,31 @@ export function RefLabels({
|
||||
/** A commit's message and metadata; `compact` (one of several selected): without the body. */
|
||||
export function CommitMessage({ commit, compact = false }: { commit: Commit; compact?: boolean }) {
|
||||
const { details, error } = useCommitDetails(commit, !compact);
|
||||
const editor = useProject((s) => s.settings?.editor);
|
||||
const { family, size } = resolveMonoFont(undefined, editor);
|
||||
const repo = commitRepo(commit) ?? currentRepo();
|
||||
const message = details?.message || commit.message;
|
||||
const [subject, ...bodyLines] = message.replace(/\s+$/, "").split("\n");
|
||||
const body = compact ? "" : bodyLines.join("\n").replace(/^\n+/, "");
|
||||
return (
|
||||
<div className={clsx(compact && styles.commitEntry)}>
|
||||
<div className={styles.subjectLine}>
|
||||
<CommitMessageText text={subject ?? ""} repo={repo} />
|
||||
</div>
|
||||
{body && (
|
||||
<div className={styles.fullMessage}>
|
||||
<CommitMessageText text={body} repo={repo} />
|
||||
<div
|
||||
className={styles.messageText}
|
||||
style={{ fontFamily: family, fontSize: size, fontWeight: fontWeightOf(editor?.fontWeight, 400) }}
|
||||
>
|
||||
<div className={styles.subjectLine} style={{ fontWeight: fontWeightOf(editor?.boldFontWeight, 700) }}>
|
||||
<CommitMessageText text={subject ?? ""} repo={repo} />
|
||||
</div>
|
||||
)}
|
||||
<div className={clsx(styles.meta, compact && styles.metaCompact)}>
|
||||
{body && (
|
||||
<div className={styles.fullMessage}>
|
||||
<CommitMessageText text={body} repo={repo} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className={styles.meta}>
|
||||
<button
|
||||
type="button"
|
||||
className={clsx(styles.linkButton, styles.hash)}
|
||||
className={styles.linkButton}
|
||||
title={tx("Copy revision number")}
|
||||
onClick={() => void writeClipboardText(commit.id)}
|
||||
>
|
||||
@@ -96,6 +106,11 @@ export function CommitMessage({ commit, compact = false }: { commit: Commit; com
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{commit.refs.length > 0 && (
|
||||
<div className={styles.meta}>
|
||||
<RefLabels refs={commit.refs} />
|
||||
</div>
|
||||
)}
|
||||
{details && (
|
||||
<>
|
||||
<div className={styles.meta}>
|
||||
@@ -125,11 +140,6 @@ export function CommitMessage({ commit, compact = false }: { commit: Commit; com
|
||||
{tx("Could not load containing branches or signature details")}
|
||||
</div>
|
||||
)}
|
||||
{commit.refs.length > 0 && (
|
||||
<div className={styles.meta}>
|
||||
<RefLabels refs={commit.refs} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user