Skip to content

fix(cli): cover every commit of a branch's first push - #309

Merged
adityankale190895 merged 1 commit into
DiffCI:mainfrom
FredApps:fix/new-branch-push-range
Nov 18, 2026
Merged

adityankale190895 merged 1 commit into
DiffCI:mainfrom
FredApps:fix/new-branch-push-range

Conversation

@FredApps

Copy link
Copy Markdown
Contributor

Fixes #308

Changed behavior

A push that creates its branch (before = forty zeros) now resolves its range from the merge base of the head with the default branch's remote-tracking ref: refs/remotes/origin/<repository.default_branch> on GitHub (or GITHUB_DEFAULT_BRANCH), refs/remotes/origin/<CI_DEFAULT_BRANCH> on GitLab. The range is source: "push-event" with mergeBaseSha set, the same range a pull request from the branch gets, so every commit the push brought is analysed.

The labelled head-parent range stays the fallback when that ref is not in the checkout, the head is already on the default branch (merge base = head), or the branch name is not a plain ref name. Pushes with a real before, pull requests and Azure are unchanged. In a fetch-depth: 1 checkout the existing unshallow retry fetches the default branch, so the second resolution finds the merge base.

Fixture and validation

New cases in packages/diffci-cli/tests/client/context.test.ts (a push that creates its branch): GitHub and GitLab merge-base ranges, the fallbacks, and a real repository whose first commit on a new branch changes src/alpha.js and second touches src/beta.js.

  • Before the fix: 3 of the new cases fail (the range is head-parent, and the diff holds only src/beta.js).
  • After: context.test.ts 34/34 pass. npm run typecheck and npm run build in packages/diffci-cli pass.

End to end with the built CLI on that repository (GITHUB_EVENT_NAME=push, zero before):

range changedFiles selectedTests full-suite-required
main head-parent src/beta.js test/beta.test.js false (alpha.test.js fails at head, not run)
this PR push-event, merge base src/alpha.js, src/beta.js test/alpha.test.js, test/beta.test.js false

Unsupported cases

When the default branch's ref is not in the checkout even after the unshallow retry, the range is still head-parent and the Action's full-suite-required still ignores that label (enforce mode already treats it as untrusted). Making impactOutputs require the full suite for head-parent would also change every Azure push build, so it is left for a separate decision.

A push that creates its branch carries before = forty zeros. The range
fell back to head^..head, so a change made in an earlier commit of the
same push was never analysed, and the Action reported
full-suite-required=false with the tests for that change left out.

Use the merge base of the head with the default branch's
remote-tracking ref (repository.default_branch on GitHub,
CI_DEFAULT_BRANCH on GitLab), recorded in mergeBaseSha, the range a pull
request from the branch would get. The labelled head-parent range stays
the fallback when that ref is not in the checkout or the head is
already on it.

Signed-off-by: FredApps <[email protected]>
@FredApps
FredApps marked this pull request as ready for review November 18, 2026 00:55
@adityankale190895
adityankale190895 merged commit 8fec8d8 into DiffCI:main Nov 18, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

observe: a branch's first push analyses only its last commit (head^..head), missing earlier commits in the push

2 participants