Repository navigation
ci(site-docs): diff frozen snapshots against the merge commit's first parent - #1123
Conversation
There was a problem hiding this comment.
The diff base is right: for pull_request, checkout lands on refs/pull/N/merge, whose first parent is the current base tip, so HEAD^1 HEAD is the PR's own contribution and the stale-base.sha blame from #1115 goes away. fetch-depth: 2 is the minimum that keeps HEAD^1 resolvable (a shallow fetch at depth 2 includes both parents of the tip), and nothing else in the job reads history: validate-site-docs.mjs only walks the filesystem, and the frozen step is skipped on push.
One nit inline, plus one thing worth knowing rather than changing: HEAD^1 only means "base tip" because checkout has no ref:. If anyone later pins it to pull_request.head.sha, the check silently narrows to the last commit on the branch instead of failing. A comment on the step would be cheaper than the debugging session.
| BASE: ${{ github.event.pull_request.base.sha }} | ||
| run: | | ||
| edited=$(git diff --diff-filter=MD --name-only "$BASE...HEAD" -- 'docs/site/docs-v*' 'docs/site/docs-fr-v*') | ||
| edited=$(git diff --diff-filter=MD --name-only HEAD^1 HEAD -- 'docs/site/docs-v*' 'docs/site/docs-fr-v*') |
There was a problem hiding this comment.
Nit (pre-existing, not introduced here): rename detection is on by default, so a file renamed within a frozen snapshot comes out as R and is filtered away by --diff-filter=MD. git mv docs/site/docs-v5/intro.md docs/site/docs-v5/getting-started.md currently passes the check even though the frozen page is gone from its old URL. --no-renames splits it back into A+D and the D is caught.
| edited=$(git diff --diff-filter=MD --name-only HEAD^1 HEAD -- 'docs/site/docs-v*' 'docs/site/docs-fr-v*') | |
| edited=$(git diff --no-renames --diff-filter=MD --name-only HEAD^1 HEAD -- 'docs/site/docs-v*' 'docs/site/docs-fr-v*') |
The frozen-snapshot check diffed
base.sha...HEAD.base.shacan be stale while HEAD is the merge with the current base tip, so changes merged to main after the PR branched were blamed on the PR (#1115 failed on #1117'sdocs-fr-v5/v6edits).Now it diffs
HEAD^1 HEAD, the PR's own contribution on top of the current base. Checkout drops tofetch-depth: 2since only the merge commit and its first parent are needed, and the unusedBASEenv is gone. Adding a newdocs-vNdirectory is still allowed.Checked locally on a throwaway repo: with a stale base the old diff reported a frozen file changed on main, the new one reported nothing; a PR that really edits a frozen file is still caught.
Closes #1122