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

Function initRepoWithNonASCIIChange

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

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

Calls 1

runGitTestFunction · 0.85

Tested by

no test coverage detected