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

Function TestRangeDiffSurvivesExternalDiffTool

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

765// (git diff <base> <to>), which likewise must pass --no-ext-diff so that a
766// user's external diff tool does not break range comparisons.
767func TestRangeDiffSurvivesExternalDiffTool(t *testing.T) {
768 repo := initRepoWithChange(t)
769
770 // Commit the change so there is a committed delta between two refs.
771 runGitTest(t, repo, "add", "sample.txt")
772 runGitTest(t, repo, "commit", "-q", "-m", "second commit")
773
774 garbage := writeGarbageExternalDiff(t)
775 t.Setenv("GIT_EXTERNAL_DIFF", garbage)
776
777 runner := gitcmd.New(0)
778 // Range: HEAD~1..HEAD -> the second commit's change.
779 provider := NewProvider(repo, "HEAD~1", "HEAD", runner)
780
781 diffs, err := provider.GetDiff(context.Background())
782 if err != nil {
783 t.Fatalf("GetDiff (range) returned error: %v", err)
784 }
785
786 if len(diffs) == 0 {
787 t.Fatalf("expected at least one parsed range diff with an external diff "+
788 "tool active, got 0 -- git diff range call site must pass "+
789 "--no-ext-diff (issue #82). GIT_EXTERNAL_DIFF=%s", garbage)
790 }
791}
792
793// TestCommitDiffMergeCommitReviewsFirstParentDiff covers `ocr review --commit
794// <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