Skip to content

Fix preview links showing unrelated content changes#185

Merged
cwickham merged 1 commit intomainfrom
fix/preview-links-diff
Apr 15, 2026
Merged

Fix preview links showing unrelated content changes#185
cwickham merged 1 commit intomainfrom
fix/preview-links-diff

Conversation

@cwickham
Copy link
Copy Markdown
Collaborator

Summary

  • Diff against the merge commit's first parent (HEAD~1) instead of origin/main when detecting content changes for preview links

Context

The detect-content job checks out refs/pull/N/merge then diffs against a freshly fetched origin/main. When main has moved ahead since the merge ref was last updated, files added to main show up as "changed" — producing preview links for content the PR didn't touch.

For example, PR #173 only changes /people/hannah-frick/ but got a preview link to /blog/2026-03-30_rag-with-raghilda/ (added to main after the PR was opened).

Since refs/pull/N/merge is a merge commit, its first parent (HEAD~1) is the base branch state at merge time. Diffing against that gives exactly the PR's changes.

Test plan

  • Trigger a preview on a PR where main has moved ahead — verify only PR-changed content appears in preview links

Diff against the merge commit's first parent (HEAD~1) instead of
origin/main. The merge ref can be stale when main moves forward,
causing files added to main after the PR was opened to appear in
the preview links.
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 15, 2026

Deploy Preview for posit-open-source canceled.

Name Link
🔨 Latest commit 34d1a0a
🔍 Latest deploy log https://app.netlify.com/projects/posit-open-source/deploys/69dfd98c3e1cc00007bf8bea

@github-actions
Copy link
Copy Markdown

@cwickham cwickham merged commit 134063a into main Apr 15, 2026
14 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.

1 participant