Skip to content

fix: recurse into submodules when resetting between base and head builds - #157

Open
liweijie0812 wants to merge 1 commit into
preactjs:masterfrom
liweijie0812:fix/submodule-recurse-on-reset
Open

liweijie0812 wants to merge 1 commit into
preactjs:masterfrom
liweijie0812:fix/submodule-recurse-on-reset

Conversation

@liweijie0812

Copy link
Copy Markdown

Problem

When switching between the PR head and the base ref, the action only runs git reset --hard <ref>. This updates the gitlink pointers in the index but does not touch submodule working trees, so in repos using git submodules the "base" build runs against the PR's submodule commits instead of the ones recorded on the base branch. Size changes coming from a submodule therefore show up as 0 B / wrong diffs.

Fix

Add --recurse-submodules to all git reset --hard calls so submodule working trees are moved to the commit recorded in the tree:

  • reset after the head build (cleans submodule changes made by the build step too)
  • git reset --hard --recurse-submodules ${baseRef} / ${baseSha} checkout of the base ref
  • reset after the base build

Notes

  • Verified with a local repro repo (superproject + submodule, different pointers on both branches): without the flag the submodule stays on the PR's commit; with the flag it correctly moves to the base commit.
  • If submodules are not initialized (e.g. actions/checkout without submodules: true), git reset --hard --recurse-submodules is a no-op and exits 0, so repos without submodule checkouts are unaffected.
  • Users still need actions/checkout with submodules: recursive for the initial checkout (unchanged requirement).

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.

1 participant