MCPcopy Create free account
hub / github.com/alibaba/open-code-review / initRepoWithNonASCIIChange

Function initRepoWithNonASCIIChange

internal/diff/git_test.go:74–99  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Calls 1

runGitTestFunction · 0.85

Tested by

no test coverage detected