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

Function initRepoWithChange

internal/diff/git_test.go:48–69  ·  view source on GitHub ↗

initRepoWithChange creates a real git repository with one committed file and an uncommitted working-tree modification, returning the repo dir. There is a genuine textual diff between HEAD and the working tree.

(t *testing.T)

Source from the content-addressed store, hash-verified

46// an uncommitted working-tree modification, returning the repo dir. There is a
47// genuine textual diff between HEAD and the working tree.
48func initRepoWithChange(t *testing.T) string {
49 t.Helper()
50 repo := t.TempDir()
51
52 runGitTest(t, repo, "init", "-q")
53 runGitTest(t, repo, "config", "user.email", "test@example.com")
54 runGitTest(t, repo, "config", "user.name", "Test User")
55 runGitTest(t, repo, "config", "commit.gpgsign", "false")
56
57 file := filepath.Join(repo, "sample.txt")
58 if err := os.WriteFile(file, []byte("line1\nline2\nline3\n"), 0o644); err != nil {
59 t.Fatalf("write sample.txt: %v", err)
60 }
61 runGitTest(t, repo, "add", "sample.txt")
62 runGitTest(t, repo, "commit", "-q", "-m", "initial commit")
63
64 // Working-tree modification: a real, parseable diff vs HEAD.
65 if err := os.WriteFile(file, []byte("line1\nCHANGED\nline3\n"), 0o644); err != nil {
66 t.Fatalf("modify sample.txt: %v", err)
67 }
68 return repo
69}
70
71// initRepoWithNonASCIIChange creates a repository whose changed file path
72// contains both non-ASCII characters and Next.js-style route groups. It forces

Calls 1

runGitTestFunction · 0.85

Tested by

no test coverage detected