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

Function initRepoWithChange

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

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

Calls 1

runGitTestFunction · 0.85

Tested by

no test coverage detected