Repository navigation
fix(beta): pass --git-ref main so edit links work - #1259
vedchaudhari wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| // This is the API docs base URL for editing a file on GitHub UI. | ||
| // GitHub can only edit files on a branch, so this can't use `{ref}` | ||
| // (`HEAD` or a tag would 404). | ||
| export const GITHUB_EDIT_URL = 'https://github.com/{repository}/edit/main'; |
There was a problem hiding this comment.
To be fair, {ref} makes sense, but it should fallback to something else if ref is not indeed a valid GitHub ref for GitHub's UI.
There was a problem hiding this comment.
Good point, updated: keeps {ref}, falls back to main when it isn't a branch.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1259 +/- ##
=======================================
Coverage 94.31% 94.31%
=======================================
Files 293 293
Lines 29912 29922 +10
Branches 3057 3058 +1
=======================================
+ Hits 28211 28221 +10
Misses 1679 1679
Partials 22 22 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
| // Refs GitHub's web editor can't open, as it only edits files on a branch: | ||
| const NON_BRANCH_REFS = [ | ||
| // `HEAD`, and revisions relative to it (`HEAD~1`, `HEAD^`) | ||
| /^HEAD([~^]\d*)*$/, | ||
| // Commit SHAs (SHA-1 or SHA-256, abbreviated or not) | ||
| /^[0-9a-f]{7,64}$/i, | ||
| // Tags, given in full or as a release version (`v24.0.0`, `1.2.3-rc.1`) | ||
| /^refs\/tags\//, | ||
| /^v?\d+\.\d+\.\d+([-+].*)?$/, | ||
| ]; |
There was a problem hiding this comment.
do we need this? Can't we change the branch in the config from HEAD to main, or something?
There was a problem hiding this comment.
Yeah, that works too and is simpler. The beta build doesn't pass --git-ref, so setting the Node preset's ref to main fixes it; the fallback only helps if someone passes HEAD or a tag. Happy to switch to just that. @ovflowd ok with you?
There was a problem hiding this comment.
@avivkeller @ovflowd any preference here? Happy to switch to just setting ref: 'main' in the Node preset if that's simpler.
There was a problem hiding this comment.
No real preference. I just wonder where HEAD comes from? Is this inferred by git via doc-kit or?
There was a problem hiding this comment.
No real preference. I just wonder where HEAD comes from? Is this inferred by git via doc-kit or?
It's not inferred from git. ref just defaults to 'HEAD' in the core config and the Node preset. That's fine for blob/raw links, since GitHub resolves it to the default branch, but /edit/HEAD/... 404s.
| export const GITHUB_EDIT_URL = 'https://github.com/{repository}/edit/{ref}'; | ||
|
|
||
| // The branch "edit this page" links use when `ref` can't be edited | ||
| export const DEFAULT_EDIT_BRANCH = 'main'; |
There was a problem hiding this comment.
I think we should just use --git-ref
There was a problem hiding this comment.
I think we should just use
--git-ref
Sounds good, I'll drop the fallback and pass --git-ref main in the beta build script instead.
Signed-off-by: vedchaudhari <vedc2853@gmail.com>
a6eebc0 to
3dfe54e
Compare
Description
"Edit this page" links on beta.docs.nodejs.org 404, e.g. https://github.com/nodejs/node/edit/HEAD/doc/api/index.md. GitHub can only edit files on a branch, and the beta build never sets
ref, so it stays on the'HEAD'default.This passes
--git-ref mainin the beta build script, so the links become.../edit/main/doc/api/<page>.md. Source links usemaintoo, which is whereHEADpointed anyway.Validation
--git-ref main: the edit link forbuffer.mdishttps://github.com/nodejs/node/edit/main/doc/api/buffer.md(without it,edit/HEAD/...).node --run test,format:checkandlintpass.Related Issues
None found.
Check List
node --run testand all tests passed.node --run format:check&node --run lint.