initRepoWithNonASCIIChange creates a repository whose changed file path contains both non-ASCII characters and Next.js-style route groups. It forces Git's default path quoting so tests do not depend on the user's global config.
(t *testing.T)
| 313 | // contains both non-ASCII characters and Next.js-style route groups. It forces |
| 314 | // Git's default path quoting so tests do not depend on the user's global config. |
| 315 | func initRepoWithNonASCIIChange(t *testing.T) (string, string) { |
| 316 | t.Helper() |
| 317 | repo := t.TempDir() |
| 318 | |
| 319 | runGitTest(t, repo, "init", "-q") |
| 320 | runGitTest(t, repo, "config", "user.email", "test@example.com") |
| 321 | runGitTest(t, repo, "config", "user.name", "Test User") |
| 322 | runGitTest(t, repo, "config", "commit.gpgsign", "false") |
| 323 | runGitTest(t, repo, "config", "core.quotepath", "true") |
| 324 | |
| 325 | relPath := "src/café/(authenticated)/文件.ts" // allow-non-english: fixture exercises non-ASCII paths |
| 326 | file := filepath.Join(repo, filepath.FromSlash(relPath)) |
| 327 | if err := os.MkdirAll(filepath.Dir(file), 0o755); err != nil { |
| 328 | t.Fatalf("create non-ASCII path: %v", err) |
| 329 | } |
| 330 | if err := os.WriteFile(file, []byte("before\n"), 0o644); err != nil { |
| 331 | t.Fatalf("write non-ASCII file: %v", err) |
| 332 | } |
| 333 | runGitTest(t, repo, "add", "--", relPath) |
| 334 | runGitTest(t, repo, "commit", "-q", "-m", "initial commit") |
| 335 | |
| 336 | if err := os.WriteFile(file, []byte("after\n"), 0o644); err != nil { |
| 337 | t.Fatalf("modify non-ASCII file: %v", err) |
| 338 | } |
| 339 | return repo, relPath |
| 340 | } |
| 341 | |
| 342 | func TestDiffModesPreserveNonASCIIPaths(t *testing.T) { |
| 343 | tests := []struct { |
no test coverage detected