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

Function writeGarbageExternalDiff

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

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

Calls

no outgoing calls

Tested by

no test coverage detected