Skip to content

fix(devtools): measure PR size against origin's default branch - #46

Merged
davidmoralesz merged 1 commit into
mainfrom
fix/pr-size-remote-base
Oct 6, 2026
Merged

davidmoralesz merged 1 commit into
mainfrom
fix/pr-size-remote-base

Conversation

@davidmoralesz

Copy link
Copy Markdown
Contributor

When check-pr-size.sh works the base out for itself and lands on the default branch, it now reads origin/<default> and only falls back to the local branch when origin has none.

Why

The local default branch only moves on a pull. A branch cut from a fresher origin/main had its merge base at the stale local main, so every file main gained in between was counted as the branch's own. Seen on #45: a 2-file change reported as 4 because local main was one merge behind.

What does not change

  • A base that was named (--base, PR_BASE) still resolves local-first, so ci-pr and explicit calls behave as before.
  • A gh stack parent that is not the trunk still resolves local-first, since a stack's layers are local branches.
  • With no origin/<default> ref, the local branch is used as before.

Tested

  • bash .devtools/test-hooks.sh: all passed, with two new cases (origin preferred for a worked-out default branch; a named base stays local).
  • shellcheck clean on both files.
  • In this checkout, with local main one commit behind: the old script reports 3/20 files changed vs main on a branch with no changes, the new one 0/20 files changed vs origin/main.

Known limit

It compares against origin as of the last fetch; it does not fetch. A push from a clone that has not fetched in a while can still overcount, and CI remains the real gate.

@davidmoralesz
davidmoralesz merged commit d26d6a8 into main Oct 6, 2026
5 checks passed
@davidmoralesz
davidmoralesz deleted the fix/pr-size-remote-base branch October 6, 2026 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant