Skip to content

test(diff): cover gitignore-drop interleaved with provider-exclude in ForEachInOrder #1297

Closed

Description

@lizhengfeng101

Description

DiffSet.ForEachInOrder (internal/diff/git.go) walks Included and Excluded
in the original changeset order using the arithmetic upTo := excludedAt[i] - i,
where excludedAt[i] is the exclusion's index in the mixed stream of included
and provider-excluded files.

That mixed-stream index deliberately does not count files dropped by
.gitignore, because partitionDiffs adds a gitignore-dropped file to neither
Included nor Excluded. The ordering is therefore correct only as long as a
gitignore-dropped file contributes to neither counter — an invariant the code
relies on but that no test exercises directly.

The existing test TestGetDiffSetWalksChangesetOrder covers an
included → provider-excluded → included interleaving (a.go, target/mid.go,
z.go), but never mixes in a gitignore-ignored file. If a future change to
partitionDiffs ever miscounted dropped files, the ordering would silently skew
and no test would catch it.

This is a test-completeness gap, not a known defect: the current logic is
correct. We want a regression test that pins the invariant.

Scope

  • File(s): internal/diff/git_test.go
  • Function/area: DiffSet.ForEachInOrder / partitionDiffs in internal/diff/git.go
  • Add a test case where the changeset interleaves all three kinds of file:
    included, provider-excluded (e.g. under target/), and gitignore-ignored,
    arranged so the gitignore-dropped file sits between an included and an
    excluded file. Assert that ForEachInOrder visits only the included and
    provider-excluded files, in the original changeset order, with correct
    providerExcluded flags, and never visits the gitignore-dropped file.

Acceptance Criteria

  • A new test in internal/diff/git_test.go covers the gitignore-drop +
    provider-exclude interleaving described above
  • The test fails if excludedAt accounting is perturbed to count dropped
    files (verify by temporarily breaking it locally)
  • Tests pass (make test)
  • Code check passes (make check)

Context

Surfaced while reviewing the ordering logic introduced in #1242. The arithmetic
was verified correct by hand across the empty / all-excluded / interleaved /
gitignore-mixed cases; this issue only fills the missing regression coverage for
the last case.

Activity

  1. added
    good first issue
    enhancement
    on Sep 16, 2026
  2. jimpablo commented on Sep 16, 2026

    @jimpablo
    Contributor

    Hi @lizhengfeng101 — I'd like to take this. I remember walking through the gitignore-mixed case by hand in #1242; happy to add the regression test that pins it.

  3. iluv7 commented on Sep 16, 2026

    @iluv7
    Contributor

    I'd like to work on this if u need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions