merge main into fix/multi-repository-git-selector

This commit is contained in:
lx
2026-08-23 02:50:34 +08:00
48 changed files with 2895 additions and 260 deletions
+32 -1
View File
@@ -1,4 +1,5 @@
import { execFile } from 'node:child_process'
import { execFile, execFileSync } from 'node:child_process'
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
import { mkdir, mkdtemp, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
@@ -44,6 +45,36 @@ describe('git parsing', () => {
])
})
it('keeps untracked files inside new directories as individual rows (status --untracked-files=all)', () => {
// status() runs with --untracked-files=all, so a new folder must surface
// as one entry PER FILE (?? newdir/a.ts), never a collapsed ?? newdir/
// row that has no diff and cannot be read (regression: new folders showed
// as a single folder row whose diff tab failed with "is a directory").
const output = ['?? newdir/a.ts', '?? newdir/sub/b.ts', ''].join('\0')
expect(parsePorcelainZ(output)).toEqual([
{ path: 'newdir/a.ts', xy: '??' },
{ path: 'newdir/sub/b.ts', xy: '??' },
])
})
it('keeps untracked files inside new directories as individual rows (real git)', async () => {
const root = mkdtempSync(join(tmpdir(), 'dsh-git-status-'))
try {
execFileSync('git', ['init', '-q'], { cwd: root })
execFileSync('git', ['config', 'user.email', 't@t'], { cwd: root })
execFileSync('git', ['config', 'user.name', 't'], { cwd: root })
execFileSync('git', ['commit', '-q', '--allow-empty', '-m', 'init'], { cwd: root })
mkdirSync(join(root, 'newdir'))
writeFileSync(join(root, 'newdir', 'a.ts'), 'x')
const result = await status(root)
const paths = result.entries.map(entry => entry.path)
expect(paths).toContain('newdir/a.ts')
expect(paths.some(path => path.endsWith('/'))).toBe(false)
} finally {
rmSync(root, { recursive: true, force: true })
}
})
it('parses log rows with unit separators (full hash + refs)', () => {
const rows = parseLogLines(
'abc1234\x1fFirst subject\x1fAlice\x1f2024-01-01 10:00:00 +0800\x1fabc1234def5678abc1234def5678abc1234def5678\x1fHEAD -> main, origin/main\n'