commit
a1dd6b0eb8
10 files changed
+194
-22
No files matched your search
@@ -16,6 +16,7 @@
|
||||
- 🧪 测试:`tests/editor-unsaved-guard.spec.tsx` 新增 2 例(后台会话的底部页面在改名后跟着走、且当前会话既没被写也没被重新发布;删除时按**它自己的**草稿先问、关在它自己的布局里)。判别性实测:把枚举收回「只看当前会话」→ 2 条红;把定向写入换回发布通道 → 2 条红;把草稿确认的会话换成当前会话 → 删除那条红。
|
||||
- **[#1013] 超过 1000 个分支/远程跟踪引用时仍可访问提交历史**:界面显示明确标注的提交列表,保留提交选择与详情。列表读取本地分支、远程分支和当前 HEAD;分页通过 Git 引用、HEAD 与 shallow 边界的状态指纹校验,状态变化时要求刷新。引用输出上限为 8 MiB,引用数量上限为 100,000,shallow 元数据上限为 1 MiB。
|
||||
- **导出插件图标子路径**:增加 `dsh-better-sidebar/icon` 包入口,方便其他包按 `exports` 规则读取 `icon.svg`。
|
||||
- **恢复提交图的 tag 显示**(#983):lightweight 与 annotated tag 装饰对应提交,行内与详情卡使用中性描边 pill,不影响 HEAD 与分支样式。Tag 独立按引用名保留前 5,000 条,并复用 8 MiB 输出上限(超限省略完整行之外的 tag,不让整页失败);不计入 1,000 分支上限。Tag 清单纳入分页指纹,创建、移动或删除 tag 后旧游标要求刷新。
|
||||
- ⚡ **页签内容不再因无关重渲染而重读整份文件**:页签 body 拿到的 `scope` 对象此前每次渲染都新建,而编辑器、差异预览、侧聊都拿它当记忆化/副作用的依赖;只要某个**被比较的字段**变了(在文件树里展开目录走 `expanded`,以及 `revealed`、语言切换、页签注册表更新),差异预览就会重跑全文改写、「内容」页重新读取整份文件并闪一下加载态。现在 `scope` 由 `useSessionScope` 按会话与 cwd 缓存,页签内容、差异页签、以及徽标 / 右侧动作区 / `+` 菜单的注册表接口共用同一份稳定对象(后三者是对外部插件公开的接口,插件对 `scope` 做记忆化不再逐渲染失效)。差异预览「内容」页的刷新改由表头刷新按钮驱动——它此前只靠这种副作用顺带刷新,改稳之后会失去刷新路径。
|
||||
- **Markdown 链接里的 Windows 反斜杠**:`[x](C:\ws\_analysis\r.md)` 的 `\_` 被 Markdown 当作转义,路径少一个分隔符(变成 `C:\ws_analysis\r.md`),点击后 `ENOENT`。源代码改写现在把本地 destination 的反斜杠统一成正斜杠(Windows 两种写法都接受),UNC 前缀保持 `\\`,避免被解析成协议相对的 `//host/share`。修复 #1037。
|
||||
- **右栏展开时仍可开关底部工作台**:会话头的底部工作台开关此前在宿主右侧面板展开时整枚隐藏,导致「先开右栏就再也打不开工作台」,必须先收起右栏。现在照常显示(它在会话头 utilities,与右栏那簇控件分属两列,不会重叠)。空白会话的 fixed 兜底入口保持原行为:那个入口锚在右栏控件左侧,展开时锚点落在面板内部。`tests/bottom-toggle.spec.tsx` 守护。
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
### 🌿 Git Graph (read-only commit graph)
|
||||
|
||||
Switch to **Git Graph** at the top of the Git panel for commit nodes, forks and merge edges across local branches, remote-tracking branches and HEAD. The branch selector only filters history — it **never checks out or fetches**; each commit is one line (lane edges + ref pills + subject), hover shows the author and short hash, and selecting one opens its full message and diff in the bottom pane. History loads in pages; reference changes during pagination prompt a refresh; reads are bounded (200 commits per page, offset 10,000, 1,000 branches) and report an explicit error past a limit. This first version shows no tags and offers no history-changing actions.
|
||||
Switch to **Git Graph** at the top of the Git panel for commit nodes, forks and merge edges across local branches, remote-tracking branches and HEAD. The branch selector only filters history — it **never checks out or fetches**; each commit is one line (lane edges + ref pills + subject), hover shows the author and short hash, and selecting one opens its full message and diff in the bottom pane. History loads in pages; reference changes during pagination prompt a refresh; reads are bounded (200 commits per page, offset 10,000, 1,000 branches) and report an explicit error past a limit. Lightweight and annotated tags appear on commits in the graph, rows and details use neutral tag pills, and tag changes invalidate pagination. Tag decorations keep the first 5,000 tags by ref name, further bounded by an 8 MiB complete-line output prefix; excess tags are omitted without failing the graph.
|
||||
|
||||
### 🧭 dsh-context diagnostics (optional)
|
||||
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@
|
||||
|
||||
### 🌿 Git Graph(只读提交图)
|
||||
|
||||
在 Git 面板顶部切到 **Git Graph**:本地分支、远程跟踪分支与 HEAD 的提交节点、分叉与合并连线。分支下拉框只筛选历史,**不会 checkout 或 fetch**;提交行是单行(泳道连线 + 引用徽章 + 标题),hover 看作者与短 hash,选中后在底部面板看完整提交信息与 diff。历史按页加载,分页期间 refs 变化会提示刷新;读取有上限(每页 200 条、偏移 10,000、分支 1,000),超限明确报错。首版不显示 tag,也不提供任何改写历史的操作。
|
||||
在 Git 面板顶部切到 **Git Graph**:本地分支、远程跟踪分支与 HEAD 的提交节点、分叉与合并连线。分支下拉框只筛选历史,**不会 checkout 或 fetch**;提交行是单行(泳道连线 + 引用徽章 + 标题),hover 看作者与短 hash,选中后在底部面板看完整提交信息与 diff。历史按页加载,分页期间 refs 变化会提示刷新;读取有上限(每页 200 条、偏移 10,000、分支 1,000),超限明确报错。图中提交支持 lightweight 与 annotated tag,提交行与详情通过中性 tag pill 标识,tag 变化会使旧分页失效。Tag 装饰按引用名保留前 5,000 条,并受 8 MiB 输出的完整行前缀限制;多余 tag 省略,不影响整张图加载。
|
||||
|
||||
### 🧭 dsh-context 诊断入口(可选)
|
||||
|
||||
|
||||
@@ -1170,6 +1170,7 @@ interface SettingsDescriptor {
|
||||
- **z-index**:面板宿主层 25、按钮簇 45——低于 DSH ui-cordis 插件面板(30)与浮层栈(100/1000+),浮层天然盖住侧边栏。
|
||||
- **更改行选中态**:Git 文件行和本轮操作行保持原有布局;选中只绘制 `--dsw-alias-interactive-bg-active` 背景,以及行内 inset 4px、宽 2px 的 `--dsw-alias-state-business-primary` 标记。选中规则与缩进参考线的绝对定位规则必须分开;`tests/theme.spec.ts` 解析实际 CSS 规则守护,挂载测试验证点击后文件行仍在原分组内。
|
||||
- **提交图高度**:更改区保持自然高度,提交图区填满固定底栏上方的剩余空间,不设 `vh` 或固定最大高度。展开的图谱分区以 248px(28px 标题 + 220px 视口)为最小高度参与 flex 分配,避免自动最小内容高度把长历史撑到外层;折叠后只保留标题,长历史在内部滚动;更改列表过长时仍由原外层滚动容器承载。预览区展开或窗口缩放后随可用空间调整,无需额外尺寸观察器。
|
||||
- **提交图的 ref pills(含 tag)**:分支/远端/HEAD 按 lane 调色板上色(五个 `--dsw-alias-state-*`);tag 是装饰而非 lane,使用中性 `--dsw-alias-label-secondary` + 虚线边框,不占 `data-color` 槽位,并以服务端返回的 `tag: ` 名称前缀作为文字 kind 标记(不新增图标/文案)。HEAD 只折叠进本地分支,tag 永不成为 current(detached HEAD 场景同样);`tests/theme.spec.ts` 钉住 tag 的 CSS 规则,`tests/git-graph-ui.spec.tsx` 钉住 tone / current / 无调色板槽位。
|
||||
|
||||
- **Context 诊断入口与提示**:图标沿用宿主 `Button` 与 `IconContextInjectionOutlineRegular`,标题栏为固定宽度按钮。跨会话错误通过 `shell.overlay` 展示一条可关闭提示,背景取 `--dsw-alias-bg-layer-3`、边框与图标取 `--dsw-alias-state-warn-primary`、正文取 label 令牌;宽度受视口约束,目标名与错误文案允许任意位置换行。能力中途消失时仍保留本次错误,不依赖来源弹层继续挂载。
|
||||
|
||||
|
||||
@@ -71,10 +71,23 @@ function remoteRefNames(branches: readonly Branch[]): ReadonlySet<string> {
|
||||
return new Set(branches.filter(item => item.ref.startsWith('refs/remotes/')).map(item => item.name))
|
||||
}
|
||||
|
||||
/** HEAD is the local-current marker; remote refs read muted, local ones brand.
|
||||
* Exported for {@link CommitDetails}, which renders the same pills. */
|
||||
export function refTone(ref: string, remotes: ReadonlySet<string>): 'head' | 'remote' | 'local' {
|
||||
/** The server's tag decoration prefix. A tag is the one ref kind that may share
|
||||
* its name with a branch, so the kind rides the name itself (`tag: v1`) rather
|
||||
* than a parallel map — and Git forbids spaces/colons in ref names, so the
|
||||
* prefix cannot collide with a real branch. */
|
||||
const TAG_PREFIX = 'tag: '
|
||||
|
||||
/** Whether a decoration is a tag (`tag: ` prefix) rather than a branch/HEAD. */
|
||||
function isTagRef(ref: string): boolean {
|
||||
return ref.startsWith(TAG_PREFIX)
|
||||
}
|
||||
|
||||
/** HEAD is the local-current marker; remote refs read muted, local ones brand,
|
||||
* tags take their own neutral rung (never a lane colour). Exported for
|
||||
* {@link CommitDetails}, which renders the same pills. */
|
||||
export function refTone(ref: string, remotes: ReadonlySet<string>): 'head' | 'remote' | 'local' | 'tag' {
|
||||
if (ref === 'HEAD') return 'head'
|
||||
if (isTagRef(ref)) return 'tag'
|
||||
return remotes.has(ref) ? 'remote' : 'local'
|
||||
}
|
||||
|
||||
@@ -82,7 +95,7 @@ export function refTone(ref: string, remotes: ReadonlySet<string>): 'head' | 're
|
||||
* carries the "currently checked out" check. */
|
||||
export interface RefPillModel {
|
||||
readonly name: string
|
||||
readonly tone: 'head' | 'remote' | 'local'
|
||||
readonly tone: 'head' | 'remote' | 'local' | 'tag'
|
||||
readonly current: boolean
|
||||
}
|
||||
|
||||
@@ -90,11 +103,13 @@ export interface RefPillModel {
|
||||
* `HEAD` never becomes a pill of its own — it folds into the current local
|
||||
* branch's pill as a leading check, the convention every graph tool shares
|
||||
* (GitLens, GitKraken, …); only a DETACHED head renders it standalone. The
|
||||
* current branch's pill takes the emphasised `head` tone. */
|
||||
* current branch's pill takes the emphasised `head` tone. Tags are skipped by
|
||||
* that fold: they are decorations, not the checked-out branch (a tag may even
|
||||
* share a branch's name). */
|
||||
export function refPills(refs: readonly string[], remotes: ReadonlySet<string>): RefPillModel[] {
|
||||
const atHead = refs.includes('HEAD')
|
||||
const named = refs.filter(ref => ref !== 'HEAD')
|
||||
const current = atHead ? named.find(ref => !remotes.has(ref)) : undefined
|
||||
const current = atHead ? named.find(ref => !isTagRef(ref) && !remotes.has(ref)) : undefined
|
||||
const pills = named.map(name => ({
|
||||
name,
|
||||
tone: (name === current ? 'head' : refTone(name, remotes)) as RefPillModel['tone'],
|
||||
@@ -108,12 +123,15 @@ export function refPills(refs: readonly string[], remotes: ReadonlySet<string>):
|
||||
* leading check when this is the branch the worktree stands on. `slot` paints
|
||||
* the pill in the commit's LANE colour (the same palette mapping the edges
|
||||
* and the node dot resolve through), so a branch head is recognisable by
|
||||
* colour alone. Shared by the graph rows, the hover card and the details
|
||||
* card so a ref reads the same everywhere. */
|
||||
* colour alone. A tag is not a lane painter: it paints the neutral label rung,
|
||||
* carries no glyph, and the server's `tag: ` name prefix is its kind marker.
|
||||
* Shared by the graph rows, the hover card and the details card so a ref reads
|
||||
* the same everywhere. */
|
||||
export function RefPill({ pill, slot }: { pill: RefPillModel; slot?: number }) {
|
||||
return <span className={css.ref} data-tone={pill.tone} data-color={slot} data-current={pill.current || undefined}>
|
||||
const tag = pill.tone === 'tag'
|
||||
return <span className={css.ref} data-tone={pill.tone} data-color={tag ? undefined : slot} data-current={pill.current || undefined}>
|
||||
{pill.current && <IconCheckOutlineRegular size={11} />}
|
||||
{pill.tone === 'remote' ? <IconGlobeOutlineRegular size={11} /> : <IconBranchOutlineRegular size={11} />}
|
||||
{!tag && (pill.tone === 'remote' ? <IconGlobeOutlineRegular size={11} /> : <IconBranchOutlineRegular size={11} />)}
|
||||
<span className={css.refName}>{pill.name}</span>
|
||||
</span>
|
||||
}
|
||||
|
||||
@@ -63,21 +63,28 @@
|
||||
/* The shared "nothing here" dash (the details card's empty parents list). */
|
||||
.dash { color: var(--dsw-alias-label-tertiary); font: var(--dsw-font-xxxs-11); }
|
||||
|
||||
/* The lane palette: five theme slots, shared by every painter — the graph
|
||||
edges and node dots and the ref pills. Colours follow the LANE, never the
|
||||
branch: a colour says "a different line", not "a unique branch" (lanes can
|
||||
outlive the branches that opened them), which is why there is deliberately
|
||||
NO legend — the ref pills on the rows are the only branch key, the
|
||||
convention every graph tool shares. The five are all STATE colours: they
|
||||
/* The lane palette: five theme slots, shared by every LANE painter — the graph
|
||||
edges and node dots and the branch/remote ref pills. Colours follow the LANE,
|
||||
never the branch: a colour says "a different line", not "a unique branch"
|
||||
(lanes can outlive the branches that opened them), which is why there is
|
||||
deliberately NO legend — the ref pills on the rows are the only branch key,
|
||||
the convention every graph tool shares. The five are all STATE colours: they
|
||||
are the tokens designed to stay legible as thin lines and small text on
|
||||
both theme families — `brand-primary` is a surface-scale navy that reads as
|
||||
a hole on the dark theme, so it is deliberately NOT a lane colour. */
|
||||
a hole on the dark theme, so it is deliberately NOT a lane colour. Tag pills
|
||||
are NOT lane painters: see the neutral rule below the palette. */
|
||||
.graph [data-color="0"], .ref[data-color="0"] { color: var(--dsw-alias-state-business-primary, var(--dsw-alias-label-primary)); }
|
||||
.graph [data-color="1"], .ref[data-color="1"] { color: var(--dsw-alias-state-success-primary, var(--dsw-alias-label-primary)); }
|
||||
.graph [data-color="2"], .ref[data-color="2"] { color: var(--dsw-alias-state-warn-primary, var(--dsw-alias-label-primary)); }
|
||||
.graph [data-color="3"], .ref[data-color="3"] { color: var(--dsw-alias-state-error-primary, var(--dsw-alias-label-primary)); }
|
||||
.graph [data-color="4"], .ref[data-color="4"] { color: var(--dsw-alias-label-secondary); }
|
||||
|
||||
/* A tag is a decoration, not a lane: it never takes a palette slot (the
|
||||
component omits `data-color` for it) and paints the neutral label rung with
|
||||
a dashed outline, so it stays distinct on both theme families. The server's
|
||||
`tag: ` name prefix is the kind marker; no glyph is added. */
|
||||
.ref[data-tone="tag"] { color: var(--dsw-alias-label-secondary); border-style: dashed; }
|
||||
|
||||
/* ── Commit details ──────────────────────────────────────────────────────
|
||||
Rendered as the changes tab's bottom-pane `details` tab (CommitDetails),
|
||||
never inside the lens any more: the pane frame, the height and the tab strip
|
||||
|
||||
+25
-3
@@ -28,6 +28,7 @@ export interface GitGraphResult {
|
||||
|
||||
const MAX_OUTPUT = 8 * 1024 * 1024
|
||||
const MAX_OFFSET = 10_000
|
||||
const MAX_GRAPH_TAGS = 5000
|
||||
const MAX_HISTORY_REFS = 100_000
|
||||
const MAX_SHALLOW_BYTES = 1024 * 1024
|
||||
const OID = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/
|
||||
@@ -37,13 +38,16 @@ const fail = (message: string, code = 'bad-request'): never => {
|
||||
|
||||
/** Separate read-only runner: bounded buffers, no prompts/lazy network fetches,
|
||||
* replacement objects or optional index writes. Never pass client revisions. */
|
||||
function readGit(cwd: string, args: string[], allowMissing = false): Promise<string> {
|
||||
function readGit(cwd: string, args: string[], allowMissing = false, truncateOutput = false): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile('git', ['-C', cwd, '--no-pager', '--no-replace-objects', '-c', 'color.ui=false', ...args], {
|
||||
encoding: 'utf8', timeout: 10_000, maxBuffer: MAX_OUTPUT, windowsHide: true,
|
||||
env: { ...process.env, LC_ALL: 'C', GIT_OPTIONAL_LOCKS: '0', GIT_TERMINAL_PROMPT: '0', GIT_NO_LAZY_FETCH: '1' },
|
||||
}, (error, stdout, stderr) => {
|
||||
if (!error) return resolve(stdout)
|
||||
// Optional decorations may retain a complete-line prefix at MAX_OUTPUT;
|
||||
// oversized tag inventories must not make the whole graph unavailable.
|
||||
if (truncateOutput && error.code === 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER') return resolve(stdout.slice(0, stdout.lastIndexOf('\n') + 1))
|
||||
if (allowMissing && error.code === 1 && !stderr.trim()) return resolve('')
|
||||
reject(new GitCommandError(stderr.trim() || error.message, 'git-error', args[0] ?? 'graph'))
|
||||
})
|
||||
@@ -74,13 +78,31 @@ async function snapshotOf(root: string, branch: string | undefined) {
|
||||
const symbolicHead = (await readGit(root, ['symbolic-ref', '--quiet', 'HEAD'], true)).trim()
|
||||
if (head && !OID.test(head)) fail('Invalid HEAD', 'git-error')
|
||||
if (!head && (!symbolicHead || branches.some(item => item.ref === symbolicHead))) fail('Cannot resolve HEAD', 'git-error')
|
||||
const fingerprint = createHash('sha256').update(JSON.stringify({ root, branch, branches, head, symbolicHead })).digest('hex')
|
||||
// Tags have their own count/output budgets: keep the first 5000 by refname
|
||||
// (or the complete-line prefix fitting MAX_OUTPUT), without consuming the
|
||||
// branch limit or adding tag-only history to the traversal.
|
||||
const rawTags = await readGit(root, ['for-each-ref', '--sort=refname', `--count=${MAX_GRAPH_TAGS}`,
|
||||
'--format=%(refname)%00%(objectname)%00%(objecttype)%00%(*objectname)%00%(*objecttype)', 'refs/tags/'], false, true)
|
||||
const tags = rawTags.trimEnd().split('\n').filter(Boolean).flatMap(line => {
|
||||
const [ref, object, type, peeled, peeledType] = line.split('\0')
|
||||
const hashFull = peeled || object
|
||||
// Use Git's peeled target for annotated tags; only commit targets
|
||||
// decorate graph entries, so tags pointing to trees/blobs are ignored.
|
||||
if ((peeled ? peeledType : type) !== 'commit') return []
|
||||
if (!ref?.startsWith('refs/tags/') || !hashFull || !OID.test(hashFull)) return fail('Invalid Git tag output', 'git-error')
|
||||
return [{ name: `tag: ${ref.slice('refs/tags/'.length)}`, hashFull }]
|
||||
})
|
||||
const fingerprint = createHash('sha256').update(JSON.stringify({ root, branch, branches, tags: rawTags, head, symbolicHead })).digest('hex')
|
||||
const selected = branch === undefined ? undefined : branches.find(item => item.ref === branch)
|
||||
const tips = branch === undefined
|
||||
? [...new Set([...branches.map(item => item.hashFull), ...(head ? [head] : [])])].sort()
|
||||
: selected ? [selected.hashFull] : []
|
||||
const decorations = new Map<string, string[]>()
|
||||
for (const item of branches) decorations.set(item.hashFull, [...(decorations.get(item.hashFull) ?? []), item.name])
|
||||
for (const item of [...branches, ...tags]) {
|
||||
const refs = decorations.get(item.hashFull) ?? []
|
||||
refs.push(item.name)
|
||||
decorations.set(item.hashFull, refs)
|
||||
}
|
||||
if (head) decorations.set(head, ['HEAD', ...(decorations.get(head) ?? [])])
|
||||
return { branches, fingerprint, tips, decorations, selected }
|
||||
}
|
||||
|
||||
@@ -269,6 +269,49 @@ describe('graph toolbar', () => {
|
||||
expect(detachedPills.map(pill => pill.getAttribute('data-color'))).toEqual(['1', '1'])
|
||||
} finally { mounted.unmount() }
|
||||
})
|
||||
|
||||
it('renders tag refs as neutral pills that never become the current branch or a lane colour', async () => {
|
||||
// The server decorates a tag with a `tag: ` prefix (a branch and a tag may
|
||||
// share a name). The pill keeps that literal text marker, takes the
|
||||
// neutral tone and never occupies a lane-palette slot; a tag is never
|
||||
// folded into HEAD as "the current branch" either.
|
||||
const branches = [
|
||||
{ ref: 'refs/heads/main', name: 'main', hashFull: HASH_A },
|
||||
{ ref: 'refs/remotes/origin/main', name: 'origin/main', hashFull: HASH_A },
|
||||
]
|
||||
const rows = [
|
||||
commit(HASH_A, ['HEAD', 'tag: v1', 'main', 'origin/main']),
|
||||
// A tag named like the local branch must not steal the fold: this
|
||||
// detached HEAD has no local branch, so HEAD stands alone and both the
|
||||
// tag and the remote stay their own kind.
|
||||
commit(HASH_B, ['HEAD', 'tag: main', 'origin/main'], [HASH_A]),
|
||||
]
|
||||
vi.spyOn(api, 'gitGraph').mockResolvedValue(graphPage(rows, branches))
|
||||
const mounted = renderRoot(createElement(GitGraphSection, defaults))
|
||||
try {
|
||||
await flush()
|
||||
const tip = mounted.container.querySelector<HTMLElement>(`[data-graph-commit="${HASH_A}"]`)!
|
||||
const pills = [...tip.querySelectorAll<HTMLElement>('[data-tone]')]
|
||||
expect(pills.map(pill => [pill.textContent, pill.getAttribute('data-tone'), pill.getAttribute('data-current')])).toEqual([
|
||||
['tag: v1', 'tag', null],
|
||||
['main', 'head', 'true'],
|
||||
['origin/main', 'remote', null],
|
||||
])
|
||||
// Tag pills wear the neutral tone; only branch/remote pills take the
|
||||
// row's lane slot.
|
||||
expect(pills.map(pill => pill.getAttribute('data-color'))).toEqual([null, '0', '0'])
|
||||
// The literal `tag: ` prefix is the kind marker — no branch or remote glyph.
|
||||
expect(pills[0]!.querySelectorAll('svg')).toHaveLength(0)
|
||||
const detached = mounted.container.querySelector<HTMLElement>(`[data-graph-commit="${HASH_B}"]`)!
|
||||
const detachedPills = [...detached.querySelectorAll<HTMLElement>('[data-tone]')]
|
||||
expect(detachedPills.map(pill => [pill.textContent, pill.getAttribute('data-tone'), pill.getAttribute('data-current')])).toEqual([
|
||||
['HEAD', 'head', 'true'],
|
||||
['tag: main', 'tag', null],
|
||||
['origin/main', 'remote', null],
|
||||
])
|
||||
expect(detachedPills[1]!.getAttribute('data-color')).toBeNull()
|
||||
} finally { mounted.unmount() }
|
||||
})
|
||||
})
|
||||
|
||||
describe('graph commit rows and details', () => {
|
||||
@@ -439,6 +482,28 @@ describe('graph commit rows and details', () => {
|
||||
expect(pills.map(pill => pill.getAttribute('data-color'))).toEqual(['3', '3'])
|
||||
} finally { mounted.unmount() }
|
||||
})
|
||||
|
||||
it('renders the tag pill in the details card without stealing the same-named branch\'s HEAD fold', async () => {
|
||||
// The details card is the other surface the user reads refs on, so a tag
|
||||
// must render there too. Same name on purpose: `tag: main` and the local
|
||||
// `main` are distinct, HEAD folds into the BRANCH, and the tag keeps the
|
||||
// neutral tone with no lane slot.
|
||||
const selected = commit(HASH_A, ['HEAD', 'tag: main', 'main'])
|
||||
const mounted = renderRoot(createElement(CommitDetails, { entry: selected, slot: 2 }))
|
||||
try {
|
||||
const details = mounted.container.querySelector<HTMLElement>(`section[aria-label="${t('graphDetails')}"]`)!
|
||||
const pills = [...details.querySelectorAll<HTMLElement>('[data-tone]')]
|
||||
expect(pills.map(pill => [pill.textContent, pill.getAttribute('data-tone'), pill.getAttribute('data-current')])).toEqual([
|
||||
['tag: main', 'tag', null],
|
||||
['main', 'head', 'true'],
|
||||
])
|
||||
expect(pills.map(pill => pill.getAttribute('data-color'))).toEqual([null, '2'])
|
||||
// The tag's literal `tag: ` text marker is its kind glyph; the current
|
||||
// branch still carries the check + branch icons.
|
||||
expect(pills[0]!.querySelectorAll('svg')).toHaveLength(0)
|
||||
expect(pills[1]!.querySelectorAll('svg')).toHaveLength(2)
|
||||
} finally { mounted.unmount() }
|
||||
})
|
||||
})
|
||||
|
||||
describe('graph end-sentinel auto-load', () => {
|
||||
|
||||
@@ -70,6 +70,51 @@ describe('read-only Git graph', () => {
|
||||
expect(filtered.entries.map(e => e.hashFull)).toEqual([topic, base])
|
||||
})
|
||||
|
||||
it('decorates commits with lightweight and annotated tags without treating tags as branches', async () => {
|
||||
const dir = repo()
|
||||
const base = commit(dir, 'base')
|
||||
const head = commit(dir, 'head')
|
||||
git(dir, '-c', 'tag.gpgsign=false', 'tag', 'release/light', base)
|
||||
git(dir, '-c', 'tag.gpgsign=false', 'tag', '-a', 'release/annotated', '-m', 'Release', head)
|
||||
const before = files(dir)
|
||||
const graph = await gitGraph(dir)
|
||||
expect(graph.entries.find(entry => entry.hashFull === base)?.refs).toContain('tag: release/light')
|
||||
expect(graph.entries.find(entry => entry.hashFull === head)?.refs).toEqual(['HEAD', 'main', 'tag: release/annotated'])
|
||||
expect(graph.branches.map(branch => branch.ref)).toEqual(['refs/heads/main'])
|
||||
expect(files(dir)).toEqual(before)
|
||||
})
|
||||
|
||||
it('invalidates graph pages when tags are created, moved or deleted', async () => {
|
||||
const dir = repo()
|
||||
const base = commit(dir, 'base')
|
||||
const head = commit(dir, 'head')
|
||||
let first = await gitGraph(dir, { count: 1 })
|
||||
git(dir, '-c', 'tag.gpgsign=false', 'tag', 'release', base)
|
||||
await expect(gitGraph(dir, { cursor: first.nextCursor })).rejects.toMatchObject({ code: 'graph-stale' })
|
||||
first = await gitGraph(dir, { count: 1 })
|
||||
git(dir, '-c', 'tag.gpgsign=false', 'tag', '-f', 'release', head)
|
||||
await expect(gitGraph(dir, { cursor: first.nextCursor })).rejects.toMatchObject({ code: 'graph-stale' })
|
||||
first = await gitGraph(dir, { count: 1 })
|
||||
git(dir, 'tag', '-d', 'release')
|
||||
await expect(gitGraph(dir, { cursor: first.nextCursor })).rejects.toMatchObject({ code: 'graph-stale' })
|
||||
})
|
||||
|
||||
it('truncates tags at their own limit while preserving branch capacity', async () => {
|
||||
const dir = repo()
|
||||
const head = commit(dir, 'head')
|
||||
const refs = [
|
||||
...Array.from({ length: 999 }, (_, i) => `create refs/heads/branch-${i} ${head}`),
|
||||
...Array.from({ length: 5001 }, (_, i) => `create refs/tags/release-${String(i).padStart(4, '0')} ${head}`),
|
||||
].join('\n') + '\n'
|
||||
execFileSync('git', ['-C', dir, 'update-ref', '--stdin'], { input: refs, env: { ...process.env, GIT_CONFIG_NOSYSTEM: '1' } })
|
||||
const graph = await gitGraph(dir)
|
||||
expect(graph.branches).toHaveLength(1000)
|
||||
const decorations = graph.entries[0]!.refs
|
||||
expect(decorations.filter(ref => ref.startsWith('tag: '))).toHaveLength(5000)
|
||||
expect(decorations).toContain('tag: release-4999')
|
||||
expect(decorations).not.toContain('tag: release-5000')
|
||||
})
|
||||
|
||||
it('includes detached HEAD but excludes stash-only history', async () => {
|
||||
const dir = repo()
|
||||
commit(dir, 'base')
|
||||
|
||||
@@ -172,6 +172,19 @@ describe('skin contract: the plugin owns no color of its own', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('tag ref pills take the neutral label token instead of a lane-palette slot', () => {
|
||||
// The graph's ref pills are painted by lane slot (`data-color` → the five
|
||||
// `--dsw-alias-state-*` colours); a tag is a decoration, not a lane, so its
|
||||
// rule must resolve to a NEUTRAL label token and keep the text marker
|
||||
// legible with a dashed outline.
|
||||
const styles = readFileSync(resolve(ROOT, 'src/client/changes/graph.module.css'), 'utf8')
|
||||
.replace(/\/\*[\s\S]*?\*\//g, '')
|
||||
const block = /\.ref\[data-tone="tag"\] \{([^}]*)\}/.exec(styles)?.[1]
|
||||
if (block === undefined) throw new Error('the tag ref pill rule must exist in graph.module.css')
|
||||
expect(block).toContain('color: var(--dsw-alias-label-secondary)')
|
||||
expect(block).toContain('border-style: dashed')
|
||||
})
|
||||
|
||||
it('the graph viewport fills its container without a viewport-relative height cap', () => {
|
||||
const sheet = document.createElement('style')
|
||||
sheet.textContent = readFileSync(resolve(ROOT, 'src/client/changes/changes.module.css'), 'utf8')
|
||||
|
||||
Reference in new issue
Block a user