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

Function writeGarbageExternalDiff

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

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

Calls

no outgoing calls

Tested by

no test coverage detected