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

Function TestRangeDiffSurvivesExternalDiffTool

internal/diff/git_test.go:447–471  ·  view source on GitHub ↗

TestRangeDiffSurvivesExternalDiffTool covers the ModeRange call site (git diff ), which likewise must pass --no-ext-diff so that a user's external diff tool does not break range comparisons.

(t *testing.T)

Source from the content-addressed store, hash-verified

445// (git diff <base> <to>), which likewise must pass --no-ext-diff so that a
446// user's external diff tool does not break range comparisons.
447func TestRangeDiffSurvivesExternalDiffTool(t *testing.T) {
448 repo := initRepoWithChange(t)
449
450 // Commit the change so there is a committed delta between two refs.
451 runGitTest(t, repo, "add", "sample.txt")
452 runGitTest(t, repo, "commit", "-q", "-m", "second commit")
453
454 garbage := writeGarbageExternalDiff(t)
455 t.Setenv("GIT_EXTERNAL_DIFF", garbage)
456
457 runner := gitcmd.New(0)
458 // Range: HEAD~1..HEAD -> the second commit's change.
459 provider := NewProvider(repo, "HEAD~1", "HEAD", runner)
460
461 diffs, err := provider.GetDiff(context.Background())
462 if err != nil {
463 t.Fatalf("GetDiff (range) returned error: %v", err)
464 }
465
466 if len(diffs) == 0 {
467 t.Fatalf("expected at least one parsed range diff with an external diff "+
468 "tool active, got 0 -- git diff range call site must pass "+
469 "--no-ext-diff (issue #82). GIT_EXTERNAL_DIFF=%s", garbage)
470 }
471}
472
473// TestCommitDiffMergeCommitReviewsFirstParentDiff covers `ocr review --commit
474// <merge>`: plain `git show` renders merge commits as a combined diff

Callers

nothing calls this directly

Calls 6

GetDiffMethod · 0.95
NewFunction · 0.92
initRepoWithChangeFunction · 0.85
runGitTestFunction · 0.85
writeGarbageExternalDiffFunction · 0.85
NewProviderFunction · 0.70

Tested by

no test coverage detected