mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-22 09:39:27 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
059c1ff8de |
No files matched your search
@@ -176,7 +176,29 @@ test("Push keeps commit subjects and changed files readable in a narrow window",
|
||||
await expect(input).toHaveValue("main");
|
||||
await expect(dialog.getByRole("button", { name: "Push", exact: true })).toBeInViewport();
|
||||
const details = dialog.getByRole("region", { name: "Commit details" });
|
||||
await expect(details).toContainText("Keep the new totals consistent with receipts.");
|
||||
await page.evaluate(async () => {
|
||||
const project = "/src/platform/project.ts";
|
||||
const { useProject } = await import(/* @vite-ignore */ project);
|
||||
const { settings } = useProject.getState();
|
||||
useProject.setState({
|
||||
settings: {
|
||||
...settings,
|
||||
editor: { ...settings?.editor, fontFamily: "Consolas", fontSize: 18, fontWeight: 400, boldFontWeight: 700 },
|
||||
},
|
||||
});
|
||||
});
|
||||
const messageSubject = details.getByText(OUTGOING, { exact: true });
|
||||
const messageBody = details.getByText("Keep the new totals consistent with receipts.", { exact: true });
|
||||
await expect(messageSubject).toHaveCSS("font-weight", "700");
|
||||
await expect(messageBody).toHaveCSS("font-weight", "400");
|
||||
await expect(messageSubject).toHaveCSS("font-size", "18px");
|
||||
await expect(messageBody).toHaveCSS("font-size", "18px");
|
||||
await expect(messageBody).toHaveCSS("font-family", /Consolas/);
|
||||
const metadata = details.getByText(/Sam Rivera <sam@example\.com>/);
|
||||
await expect(metadata).toHaveCSS("font-size", "12px");
|
||||
await metadata.scrollIntoViewIfNeeded();
|
||||
await expect(metadata).toBeInViewport();
|
||||
expect(await details.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const [tree, message] = await Promise.all([files.boundingBox(), details.boundingBox()]);
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import type { Commit } from "@/bindings";
|
||||
import type { ReactNode } from "react";
|
||||
import { fontWeightOf } from "@/platform/editorSettings";
|
||||
import { resolveMonoFont } from "@/platform/fonts";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { useProject } from "@/platform/project";
|
||||
import styles from "./GitLog.module.css";
|
||||
|
||||
export function CommitMessageContent({
|
||||
commit,
|
||||
message,
|
||||
compact = false,
|
||||
renderText = (text) => text,
|
||||
revision = commit.shortId,
|
||||
}: {
|
||||
commit: Commit;
|
||||
message: string;
|
||||
compact?: boolean;
|
||||
renderText?: (text: string) => ReactNode;
|
||||
revision?: ReactNode;
|
||||
}) {
|
||||
const editor = useProject((s) => s.settings?.editor);
|
||||
const { family, size } = resolveMonoFont(undefined, editor);
|
||||
const [subject = "", ...bodyLines] = message.trimEnd().split("\n");
|
||||
const body = compact ? "" : bodyLines.join("\n").replace(/^\n+/, "");
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className={styles.messageText}
|
||||
style={{ fontFamily: family, fontSize: size, fontWeight: fontWeightOf(editor?.fontWeight, 400) }}
|
||||
>
|
||||
<div className={styles.subjectLine} style={{ fontWeight: fontWeightOf(editor?.boldFontWeight, 700) }}>
|
||||
{renderText(subject)}
|
||||
</div>
|
||||
{body && <div className={styles.fullMessage}>{renderText(body)}</div>}
|
||||
</div>
|
||||
<div className={styles.meta}>
|
||||
{revision} {commit.author} <{commit.email}>
|
||||
{commit.timeMs ? " " + tx`on ${new Date(commit.timeMs).toLocaleString()}` : ""}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import { executeAction } from "@/platform/actions";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { Button, IconButton, Spinner, SplitGroup, SplitHandle, SplitPanel, T } from "@/ui";
|
||||
import { CommitMessageContent } from "./CommitMessageContent";
|
||||
import { ComparisonTree } from "./ComparisonTree";
|
||||
import { buildFileTree } from "./fileTree";
|
||||
import { flatFileNodes, toLogChanges, type LogChange } from "./logChanges";
|
||||
@@ -151,14 +152,9 @@ export function PushChanges({
|
||||
|
||||
/** The selected commit's full message, revision, author and time. */
|
||||
function PushCommitDetails({ commit }: { commit: Commit }) {
|
||||
const date = commit.timeMs ? new Date(commit.timeMs).toLocaleString() : null;
|
||||
return (
|
||||
<section className={styles.pushCommitDetails} aria-label={tx("Commit details")}>
|
||||
<div className={styles.pushCommitMessage}>{commit.message.trimEnd() || commit.summary}</div>
|
||||
<div className={styles.fileDir}>
|
||||
{commit.shortId} {commit.author} <{commit.email}>
|
||||
{date ? " " + tx`on ${date}` : ""}
|
||||
</div>
|
||||
<CommitMessageContent commit={commit} message={commit.message.trimEnd() || commit.summary} />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { fireEvent, render, screen, within } from "@testing-library/react";
|
||||
import type { Commit } from "@/bindings";
|
||||
|
||||
const { files, combined, executeAction } = vi.hoisted(() => ({
|
||||
@@ -69,8 +69,10 @@ describe("Push dialog changes", () => {
|
||||
const one = { ...older, message: "Add order service\n\nIntroduces the service.\n", timeMs: 1_700_000_000_000 };
|
||||
render(<PushChanges repo="/r" commits={[one]} />);
|
||||
const details = screen.getByRole("region", { name: "Commit details" });
|
||||
expect(details.textContent).toContain("Add order service\n\nIntroduces the service.");
|
||||
expect(details.textContent).toContain("aaaaaaa me <[email protected]> on ");
|
||||
const message = within(details);
|
||||
expect(message.getByText("Add order service", { exact: true })).toBeTruthy();
|
||||
expect(message.getByText("Introduces the service.", { exact: true })).toBeTruthy();
|
||||
expect(message.getByText(/^aaaaaaa me <me@example\.com> on /)).toBeTruthy();
|
||||
expect(await screen.findByText("src/orders")).toBeTruthy();
|
||||
expect(screen.getAllByRole("treeitem")).toHaveLength(2);
|
||||
const grouping = screen.getByRole("button", { name: "Group by Directory" });
|
||||
|
||||
@@ -363,9 +363,6 @@
|
||||
.pushCommitDetails {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
margin: var(--space-1) var(--space-3);
|
||||
padding: var(--space-1) var(--space-2);
|
||||
overflow: auto;
|
||||
@@ -374,11 +371,6 @@
|
||||
-webkit-user-select: text;
|
||||
user-select: text;
|
||||
}
|
||||
.pushCommitMessage {
|
||||
color: var(--fg-strong);
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.todoList {
|
||||
margin: 8px 0 0;
|
||||
padding-left: 18px;
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
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 { CommitMessageContent } from "../CommitMessageContent";
|
||||
import styles from "../GitLog.module.css";
|
||||
import { IssueText } from "../issueLinks";
|
||||
import { useCommitDetails } from "../logDetails";
|
||||
@@ -50,39 +48,25 @@ 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.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>
|
||||
{body && (
|
||||
<div className={styles.fullMessage}>
|
||||
<CommitMessageText text={body} repo={repo} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className={styles.meta}>
|
||||
<button
|
||||
type="button"
|
||||
className={styles.linkButton}
|
||||
title={tx("Copy revision number")}
|
||||
onClick={() => void writeClipboardText(commit.id)}
|
||||
>
|
||||
{commit.shortId}
|
||||
</button>{" "}
|
||||
{commit.author} <{commit.email}>
|
||||
{commit.timeMs ? " " + tx`on ${new Date(commit.timeMs).toLocaleString()}` : ""}
|
||||
</div>
|
||||
<CommitMessageContent
|
||||
commit={commit}
|
||||
message={details?.message || commit.message}
|
||||
compact={compact}
|
||||
renderText={(text) => <CommitMessageText text={text} repo={repo} />}
|
||||
revision={
|
||||
<button
|
||||
type="button"
|
||||
className={styles.linkButton}
|
||||
title={tx("Copy revision number")}
|
||||
onClick={() => void writeClipboardText(commit.id)}
|
||||
>
|
||||
{commit.shortId}
|
||||
</button>
|
||||
}
|
||||
/>
|
||||
{!compact &&
|
||||
commit.committer &&
|
||||
(commit.committer !== commit.author ||
|
||||
|
||||
Reference in new issue
Block a user