Compare commits

...
Author SHA1 Message Date
l0ng-ai 756f147765 fix(vcs): group branches and tags in commit details 2026-11-23 03:55:47 +08:00
2 changed files with 29 additions and 13 deletions

No files matched your search

+6 -5
View File
@@ -703,15 +703,16 @@
padding-top: 10px;
border-top: 1px solid var(--border);
}
.meta .refs {
margin-left: 0;
max-width: none;
.detailRefGroup {
display: flex;
flex-wrap: wrap;
gap: var(--space-0-5) var(--space-2);
}
.meta .ref {
.detailRefGroup .ref {
align-items: baseline;
font-size: inherit;
max-width: 100%;
white-space: normal;
overflow-wrap: anywhere;
}
.hash {
font-family: var(--font-mono);
+23 -8
View File
@@ -7,7 +7,7 @@ import { CommitMessageContent } from "../CommitMessageContent";
import styles from "../GitLog.module.css";
import { IssueText } from "../issueLinks";
import { useCommitDetails } from "../logDetails";
import { refLabels } from "../logOptions";
import { refLabels, type RefLabel } from "../logOptions";
import { goToRef } from "../logStore";
import { commitRepo } from "../multiRoot";
import { currentRepo } from "../store";
@@ -34,9 +34,18 @@ export function RefLabels({
remoteNames?: ReadonlySet<string>;
left?: boolean;
}) {
const labels = refLabels(refs, { compact, tagNames }, remoteNames);
return (
<span className={clsx(styles.refs, compact && styles.refsCompact, left && styles.refsLeft)}>
<RefGroup
labels={refLabels(refs, { compact, tagNames }, remoteNames)}
className={clsx(styles.refs, compact && styles.refsCompact, left && styles.refsLeft)}
/>
);
}
function RefGroup({ labels, className }: { labels: RefLabel[]; className: string | undefined }) {
if (!labels.length) return null;
return (
<span className={className}>
{labels.map((l) => (
<span key={`${l.kind}:${l.title}`} className={clsx(styles.ref, REF_KIND_CLASS[l.kind])} title={l.title}>
{l.text && <span className={styles.refText}>{l.text}</span>}
@@ -46,6 +55,16 @@ export function RefLabels({
);
}
function CommitReferences({ refs }: { refs: string[] }) {
const labels = refLabels(refs, { compact: false, tagNames: true }, NO_REMOTES);
return (
<div className={styles.meta}>
<RefGroup labels={labels.filter((label) => label.kind !== "tag")} className={styles.detailRefGroup} />
<RefGroup labels={labels.filter((label) => label.kind === "tag")} className={styles.detailRefGroup} />
</div>
);
}
/** 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);
@@ -91,11 +110,7 @@ export function CommitMessage({ commit, compact = false }: { commit: Commit; com
))}
</div>
)}
{commit.refs.length > 0 && (
<div className={styles.meta}>
<RefLabels refs={commit.refs} />
</div>
)}
{commit.refs.length > 0 && <CommitReferences refs={commit.refs} />}
{details && (
<>
<div className={styles.meta}>