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

Function shimGit

internal/diff/git_error_test.go:159–169  ·  view source on GitHub ↗

shimGit puts a fake `git` at the front of PATH for the duration of the test.

(t *testing.T, body string)

Source from the content-addressed store, hash-verified

157
158// shimGit puts a fake `git` at the front of PATH for the duration of the test.
159func shimGit(t *testing.T, body string) {
160 t.Helper()
161 if runtime.GOOS == "windows" {
162 t.Skip("PATH shim relies on a shebang script")
163 }
164 dir := t.TempDir()
165 if err := os.WriteFile(filepath.Join(dir, "git"), []byte("#!/bin/sh\n"+body), 0o755); err != nil {
166 t.Fatalf("write git shim: %v", err)
167 }
168 t.Setenv("PATH", dir+string(os.PathListSeparator)+os.Getenv("PATH"))
169}
170
171// TestGetDiff_FailureQuotesStderrNotStdout pins the split that keeps repository
172// content out of the error.

Calls

no outgoing calls

Tested by

no test coverage detected