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

Function writeGarbageExternalDiff

internal/diff/git_test.go:35–45  ·  view source on GitHub ↗

writeGarbageExternalDiff writes a shell script that emits non-diff output and returns its path. When git invokes it via GIT_EXTERNAL_DIFF / diff.external it replaces the normal unified-diff machinery, so the output can no longer be parsed into model.Diff structs unless the git command opts out with

(t *testing.T)

Source from the content-addressed store, hash-verified

33// parsed into model.Diff structs unless the git command opts out with
34// --no-ext-diff.
35func writeGarbageExternalDiff(t *testing.T) string {
36 t.Helper()
37 dir := t.TempDir()
38 script := filepath.Join(dir, "garbage-diff.sh")
39 // GIT_EXTERNAL_DIFF programs receive 7 args; we ignore them and print junk.
40 body := "#!/bin/sh\necho \"not a diff\"\n"
41 if err := os.WriteFile(script, []byte(body), 0o755); err != nil {
42 t.Fatalf("write garbage diff script: %v", err)
43 }
44 return script
45}
46
47// initRepoWithChange creates a real git repository with one committed file and
48// an uncommitted working-tree modification, returning the repo dir. There is a

Calls

no outgoing calls

Tested by

no test coverage detected