FE-1457: Point source links at the branch being built - #9267
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
PR SummaryLow Risk Overview
Reviewed by Cursor Bugbot for commit b7d1d5d. Bugbot is set up for automated code reviews on this repo. Configure here. |
3784d1f to
ee92518
Compare
ee92518 to
621b82c
Compare
621b82c to
0e56bd5
Compare
e0f070e to
b0f7f82
Compare
b0f7f82 to
468e8e7
Compare
468e8e7 to
e12b8f3
Compare
e12b8f3 to
8c1d785
Compare
🌟 What is the purpose of this PR?
Every generated page links to the file that declared its layer, and the link target was hardcoded to
main. On a preview build those links showed the pre-change file, or 404'd for a file the branch adds. The ref now comes from the build environment:FE-1456 (#9266) sits below in this stack and FE-1455 (#9268) above.
🔗 Related links
🔍 What does this change?
src/source-url.ts(new): resolves the ref from the first variable holding a value, in orderPETRINAUT_ARCH_DOCS_SOURCE_REF,VERCEL_GIT_COMMIT_SHA,GITHUB_SHA,VERCEL_GIT_COMMIT_REF,GITHUB_HEAD_REF,GITHUB_REF_NAME, defaulting tomain. A SHA beats a branch name because the link still resolves after the branch moves or is deleted. Slashes stay literal as blob-path separators,#and%are encoded, and empty or dot-only segments are dropped, which git refnames forbid anyway.architecture.config.ts:sourceUrlPrefixcalls the resolver, and no literalmainremains.turbo.json: the six variables are declared indoc:architecture'senv, which strict env mode would otherwise hide from the task. A comment on each side says to keep the two lists identical.vercel-build.shand the generator's "Wrote" line both name the resolved ref, so a preview build's log shows which commit its links point at.hashintel/hash, soGITHUB_HEAD_REFnames a branch this repository does not have and the link 404s. The SHA variables win when present and resolve regardless.No workflow changes: nothing under
.github/workflows/builds the bundle, and GitHub Actions already exports the variables the resolver reads.Pre-Merge Checklist 🚀
🚢 Has this modified a publishable library?
This PR:
📜 Does this require a change to the docs?
The changes in this PR:
🕸️ Does this require a change to the Turbo Graph?
The changes in this PR:
turbo.json's have been updated to reflect thisdoc:architecturedeclares the ref variables. The task and its consumers are uncached, so a ref change cannot serve stale links.🛡 What tests cover this?
source-url.test.ts: the default, blank values skipped, SHA over branch for both providers, the local override over both, a branch name containing a slash, and#encoding.❓ How to test this?
yarn workspace @local/petrinaut-arch-docs doc:architectureand grep adeclaredInUrlinbundle/pages/architecture/cli.mdx: it points atblob/main/.GITHUB_HEAD_REF=<a branch>: the same link points at that branch. AddingGITHUB_SHA=<sha>switches it to the SHA.🐾 Next steps
Two hand-written
blob/main/...links remain in authored MDX. Those name specific files as references rather than being generated source links; giving them the same treatment needs a link helper in the authoring syntax.🤖 Generated with Claude Code