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)
| 69 | // contains both non-ASCII characters and Next.js-style route groups. It forces |
| 70 | // Git's default path quoting so tests do not depend on the user's global config. |
| 71 | func initRepoWithNonASCIIChange(t *testing.T) (string, string) { |
| 72 | t.Helper() |
| 73 | repo := t.TempDir() |
| 74 | |
| 75 | runGitTest(t, repo, "init", "-q") |
| 76 | runGitTest(t, repo, "config", "user.email", "test@example.com") |
| 77 | runGitTest(t, repo, "config", "user.name", "Test User") |
| 78 | runGitTest(t, repo, "config", "commit.gpgsign", "false") |
| 79 | runGitTest(t, repo, "config", "core.quotepath", "true") |
| 80 | |
| 81 | relPath := "src/café/(authenticated)/文件.ts" |
| 82 | file := filepath.Join(repo, filepath.FromSlash(relPath)) |
| 83 | if err := os.MkdirAll(filepath.Dir(file), 0o755); err != nil { |
| 84 | t.Fatalf("create non-ASCII path: %v", err) |
| 85 | } |
| 86 | if err := os.WriteFile(file, []byte("before\n"), 0o644); err != nil { |
| 87 | t.Fatalf("write non-ASCII file: %v", err) |
| 88 | } |
| 89 | runGitTest(t, repo, "add", "--", relPath) |
| 90 | runGitTest(t, repo, "commit", "-q", "-m", "initial commit") |
| 91 | |
| 92 | if err := os.WriteFile(file, []byte("after\n"), 0o644); err != nil { |
| 93 | t.Fatalf("modify non-ASCII file: %v", err) |
| 94 | } |
| 95 | return repo, relPath |
| 96 | } |
| 97 | |
| 98 | func TestDiffModesPreserveNonASCIIPaths(t *testing.T) { |
| 99 | tests := []struct { |
no test coverage detected