native macOS codings agent orchestrator
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #10 from onevcat/fix/diff-chinese-filenames

fix: show unescaped chinese/unicode filenames in git diff

authored by

Wei Wang and committed by
GitHub
95ffe378 d7a1aa49

+65 -2
+2 -2
supacode/Clients/Git/GitClient.swift
··· 456 456 do { 457 457 return try await runGit( 458 458 operation: .diffNameStatus, 459 - arguments: ["-C", path, "diff", "HEAD", "--name-status"] 459 + arguments: ["-C", path, "-c", "core.quotePath=false", "diff", "HEAD", "--name-status"] 460 460 ) 461 461 } catch { 462 462 return "" ··· 468 468 do { 469 469 let output = try await runGit( 470 470 operation: .untrackedFilePaths, 471 - arguments: ["-C", path, "ls-files", "--others", "--exclude-standard"] 471 + arguments: ["-C", path, "-c", "core.quotePath=false", "ls-files", "--others", "--exclude-standard"] 472 472 ) 473 473 return 474 474 output
+63
supacodeTests/GitClientDiffPathEncodingTests.swift
··· 1 + import Foundation 2 + import Testing 3 + 4 + @testable import supacode 5 + 6 + actor DiffPathShellCallStore { 7 + private(set) var calls: [[String]] = [] 8 + 9 + func record(_ arguments: [String]) { 10 + calls.append(arguments) 11 + } 12 + } 13 + 14 + struct GitClientDiffPathEncodingTests { 15 + @Test func diffNameStatusDisablesQuotePath() async { 16 + let store = DiffPathShellCallStore() 17 + let shell = ShellClient( 18 + run: { _, arguments, _ in 19 + await store.record(arguments) 20 + return ShellOutput(stdout: "M\t中文文件.md\n", stderr: "", exitCode: 0) 21 + }, 22 + runLoginImpl: { _, _, _, _ in ShellOutput(stdout: "", stderr: "", exitCode: 0) } 23 + ) 24 + let client = GitClient(shell: shell) 25 + 26 + let output = await client.diffNameStatus(at: URL(fileURLWithPath: "/tmp/repo")) 27 + 28 + #expect(output.contains("中文文件.md")) 29 + let calls = await store.calls 30 + #expect(calls.count == 1) 31 + let args = calls[0] 32 + #expect(args.first == "git") 33 + #expect(args.contains("-c")) 34 + #expect(args.contains("core.quotePath=false")) 35 + #expect(args.contains("diff")) 36 + #expect(args.contains("--name-status")) 37 + } 38 + 39 + @Test func untrackedFilePathsDisablesQuotePath() async { 40 + let store = DiffPathShellCallStore() 41 + let shell = ShellClient( 42 + run: { _, arguments, _ in 43 + await store.record(arguments) 44 + return ShellOutput(stdout: "中文文件.md\n", stderr: "", exitCode: 0) 45 + }, 46 + runLoginImpl: { _, _, _, _ in ShellOutput(stdout: "", stderr: "", exitCode: 0) } 47 + ) 48 + let client = GitClient(shell: shell) 49 + 50 + let paths = await client.untrackedFilePaths(at: URL(fileURLWithPath: "/tmp/repo")) 51 + 52 + #expect(paths == ["中文文件.md"]) 53 + let calls = await store.calls 54 + #expect(calls.count == 1) 55 + let args = calls[0] 56 + #expect(args.first == "git") 57 + #expect(args.contains("-c")) 58 + #expect(args.contains("core.quotePath=false")) 59 + #expect(args.contains("ls-files")) 60 + #expect(args.contains("--others")) 61 + #expect(args.contains("--exclude-standard")) 62 + } 63 + }