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

Function initRepoWithNonASCIIChange

internal/diff/git_test.go:209–234  ·  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

207// contains both non-ASCII characters and Next.js-style route groups. It forces
208// Git's default path quoting so tests do not depend on the user's global config.
209func initRepoWithNonASCIIChange(t *testing.T) (string, string) {
210 t.Helper()
211 repo := t.TempDir()
212
213 runGitTest(t, repo, "init", "-q")
214 runGitTest(t, repo, "config", "user.email", "test@example.com")
215 runGitTest(t, repo, "config", "user.name", "Test User")
216 runGitTest(t, repo, "config", "commit.gpgsign", "false")
217 runGitTest(t, repo, "config", "core.quotepath", "true")
218
219 relPath := "src/café/(authenticated)/文件.ts" // allow-non-english: fixture exercises non-ASCII paths
220 file := filepath.Join(repo, filepath.FromSlash(relPath))
221 if err := os.MkdirAll(filepath.Dir(file), 0o755); err != nil {
222 t.Fatalf("create non-ASCII path: %v", err)
223 }
224 if err := os.WriteFile(file, []byte("before\n"), 0o644); err != nil {
225 t.Fatalf("write non-ASCII file: %v", err)
226 }
227 runGitTest(t, repo, "add", "--", relPath)
228 runGitTest(t, repo, "commit", "-q", "-m", "initial commit")
229
230 if err := os.WriteFile(file, []byte("after\n"), 0o644); err != nil {
231 t.Fatalf("modify non-ASCII file: %v", err)
232 }
233 return repo, relPath
234}
235
236func TestDiffModesPreserveNonASCIIPaths(t *testing.T) {
237 tests := []struct {

Calls 1

runGitTestFunction · 0.85

Tested by

no test coverage detected