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

Function TestRangeDiffSurvivesExternalDiffTool

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

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