changeset-check.yml resolves its diff base differently from pre-commit.yml, and the difference costs a full-history clone on every PR.
Current state
changeset-check.yml:
- uses: actions/checkout@v7
with:
fetch-depth: 0
...
- run: pnpm exec changeset status --since=origin/main
pre-commit.yml, which gets this right:
- uses: actions/checkout@v7 # no fetch-depth — shallow is fine
...
- env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: mise run hk:base -- "$BASE_SHA"
Two separate problems.
1. Hardcoded origin/main
The base is assumed rather than read from the event. A PR targeting anything other than main — a release branch, a stacked PR — is diffed against the wrong base. github.event.pull_request.base.sha is the base GitHub actually recorded, and is what pre-commit.yml already uses.
2. fetch-depth: 0 as a workaround for shallow-clone breakage
changeset status --since cannot run on a shallow clone. @changesets/git's getChangedFilesSince shells out to git merge-base <ref> HEAD and diffs from the divergence point, which needs common ancestry the shallow clone does not have. fetch-depth: 0 sidesteps that by cloning all history on every PR run.
gtb hk base solves the same problem properly: it detects git rev-parse --is-shallow-repository and fetches just the base before diffing (executeHkBase in packages/cli/src/commands/root/hk.ts), so pre-commit.yml needs no fetch-depth at all.
Note the two gates in this workflow have different needs. gtb changeset check only reads the base commit's tree (rev-parse --verify, cat-file -e, git show <base>:pnpm-workspace.yaml) — a depth-1 fetch of the base would satisfy it. Only changeset status needs real ancestry.
Suggested fix
- Pass
github.event.pull_request.base.sha to both steps instead of origin/main.
- Port the shallow-detect-and-fetch handling from
executeHkBase so the checkout can drop fetch-depth: 0. Since changeset status needs merge-base ancestry rather than just the base commit, this likely needs a deepening fetch (--deepen / --shallow-since) rather than the --depth=1 that suffices for hk, so it needs measuring before committing to it.
- Consider extracting the shared base-ref resolution so
gtb hk and gtb changeset check don't drift apart.
Deferred out of the PR that added gtb changeset check, which kept the existing convention rather than changing base resolution for the stock changeset status gate at the same time.
changeset-check.ymlresolves its diff base differently frompre-commit.yml, and the difference costs a full-history clone on every PR.Current state
changeset-check.yml:pre-commit.yml, which gets this right:Two separate problems.
1. Hardcoded
origin/mainThe base is assumed rather than read from the event. A PR targeting anything other than
main— a release branch, a stacked PR — is diffed against the wrong base.github.event.pull_request.base.shais the base GitHub actually recorded, and is whatpre-commit.ymlalready uses.2.
fetch-depth: 0as a workaround for shallow-clone breakagechangeset status --sincecannot run on a shallow clone.@changesets/git'sgetChangedFilesSinceshells out togit merge-base <ref> HEADand diffs from the divergence point, which needs common ancestry the shallow clone does not have.fetch-depth: 0sidesteps that by cloning all history on every PR run.gtb hk basesolves the same problem properly: it detectsgit rev-parse --is-shallow-repositoryand fetches just the base before diffing (executeHkBaseinpackages/cli/src/commands/root/hk.ts), sopre-commit.ymlneeds nofetch-depthat all.Note the two gates in this workflow have different needs.
gtb changeset checkonly reads the base commit's tree (rev-parse --verify,cat-file -e,git show <base>:pnpm-workspace.yaml) — a depth-1 fetch of the base would satisfy it. Onlychangeset statusneeds real ancestry.Suggested fix
github.event.pull_request.base.shato both steps instead oforigin/main.executeHkBaseso the checkout can dropfetch-depth: 0. Sincechangeset statusneeds merge-base ancestry rather than just the base commit, this likely needs a deepening fetch (--deepen/--shallow-since) rather than the--depth=1that suffices for hk, so it needs measuring before committing to it.gtb hkandgtb changeset checkdon't drift apart.Deferred out of the PR that added
gtb changeset check, which kept the existing convention rather than changing base resolution for the stockchangeset statusgate at the same time.