Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

fix(turnrewind): ignore CR-at-EOL in preview and conflict diffs like the conflict check

yingtianlan294466376f6e
diff --git a/packages/dsh-tauri-turnrewind-ts/src/host/service/git-snapshot.ts b/packages/dsh-tauri-turnrewind-ts/src/host/service/git-snapshot.ts
index 8edfbf77..261a9f5e 100644
--- a/packages/dsh-tauri-turnrewind-ts/src/host/service/git-snapshot.ts
+++ b/packages/dsh-tauri-turnrewind-ts/src/host/service/git-snapshot.ts
@@ -503,7 +503,9 @@ export async function classifyPathChange(store: SnapshotStore, beforeCommit: str
export async function snapshotFileDiff(store: SnapshotStore, fromCommit: string, toCommit: string, path: string, maxLines?: number): Promise<string> {
assertCommitRef(fromCommit)
assertCommitRef(toCommit)
- const output = await runGit(store.repoDir, store.workspaceDir, ['diff', '--no-renames', fromCommit, toCommit, '--', path])
+ // --ignore-cr-at-eol 与冲突检测的 CRLF 规范化同语义:换行符翻转不画成
+ // 幽灵增删(同一行删一遍又加一遍),预览只呈现内容变化。
+ const output = await runGit(store.repoDir, store.workspaceDir, ['diff', '--no-renames', '--ignore-cr-at-eol', fromCommit, toCommit, '--', path])
return truncateDiff(output.toString('utf8'), maxLines)
}
@@ -551,6 +553,7 @@ export async function diffAgainstDisk(store: SnapshotStore, commit: string, path
const output = await runGit(store.repoDir, store.workspaceDir, [
'diff',
'--no-renames',
+ '--ignore-cr-at-eol',
'--src-prefix=snapshot/',
'--dst-prefix=disk/',
from,
diff --git a/packages/dsh-tauri-turnrewind-ts/test/git-snapshot.test.js b/packages/dsh-tauri-turnrewind-ts/test/git-snapshot.test.js
index 9c79ea79..846e2931 100644
--- a/packages/dsh-tauri-turnrewind-ts/test/git-snapshot.test.js
+++ b/packages/dsh-tauri-turnrewind-ts/test/git-snapshot.test.js
@@ -203,6 +203,32 @@ it('does not treat CRLF conversion as a file conflict', async () => {
}
})
+it('renders a line-ending flip plus appends without phantom duplicate lines', async () => {
+ const root = await mkdtemp(join(tmpdir(), 'turnrewind-crlf-diff-'))
+ const workspace = join(root, 'workspace')
+ try {
+ await initGitWorkspace(workspace)
+ // Pre-turn file with CRLF endings (the Windows checkout norm).
+ await writeFile(join(workspace, 'modified3.txt'), '文件 3\r\n用于测试 undo。\r\n')
+ const store = createSnapshotStore(join(root, 'data'), workspace)
+ const before = await captureSnapshot(store, 'refs/turnrewind/crlfdiff-before', 'before')
+ // The turn rewrites the same content with LF endings and appends two lines.
+ await writeFile(join(workspace, 'modified3.txt'), '文件 3\n用于测试 undo。\n额外追加一行。\n额外追加第二行。')
+ const after = await captureSnapshot(store, 'refs/turnrewind/crlfdiff-after', 'after', before.commit)
+
+ // Byte-exact git cannot pair the two visually identical lines; the
+ // --ignore-cr-at-eol preview keeps the ending flip from rendering the
+ // line as both deleted and added — only the real content change shows.
+ const undoDiff = await snapshotFileDiff(store, after.commit, before.commit, 'modified3.txt')
+ assert.match(undoDiff, /-额外追加一行。/u)
+ assert.match(undoDiff, /-额外追加第二行。/u)
+ assert.doesNotMatch(undoDiff, /\+用于测试 undo。/u)
+ }
+ finally {
+ await rm(root, { recursive: true, force: true })
+ }
+})
+
it('classifies path changes and produces codex-style diffs', async () => {
const root = await mkdtemp(join(tmpdir(), 'turnrewind-diff-test-'))
const workspace = join(root, 'workspace')