Repository navigation
Get the URL and the repository from browser-specs #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
deniak
wants to merge
7
commits into
main
Choose a base branch
from
browser-specs-url-repo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
90bb22d
use browser-specs to fetch the URL and the repository of each spec
deniak 44e4bea
the repository can now be null
deniak 7dd8e17
add tests for specs.js
deniak 6c76f44
add tests when WPT path doesn't match the web feature ID + empty cont…
deniak da8dd3a
update documentation
deniak b54d40a
regenerate data
deniak 1cace49
No need to specify index.json
deniak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /** | ||
| * Resolves the entries of specs.json against browser-specs. | ||
| */ | ||
| import webSpecs from "web-specs/index.json" with { type: "json" }; | ||
|
deniak marked this conversation as resolved.
Outdated
|
||
| import { logger } from "./logger.js"; | ||
|
|
||
| // Track former shortname so that an old shortname used in specs.json can still be resolved | ||
| const byShortname = new Map(); | ||
| const byFormerName = new Map(); | ||
| for (const spec of webSpecs) { | ||
| byShortname.set(spec.shortname, spec); | ||
| for (const former of spec.formerNames ?? []) { | ||
| byFormerName.set(former, spec); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * The `owner/name` from the full GitHub repository URL | ||
| * | ||
| * @param {string | undefined} repository | ||
| * @returns {string | null} | ||
| */ | ||
| export function githubRepo(repository) { | ||
| if (!repository) return null; | ||
| let url; | ||
| try { | ||
| url = new URL(repository); | ||
| } catch { | ||
| return null; | ||
| } | ||
| // TODO: Add support for repositories hosted on platforms other than GitHub | ||
| if (url.hostname !== "github.com") return null; | ||
| const path = url.pathname.replace(/^\//, "").replace(/\.git$/, ""); | ||
| return /^[^/]+\/[^/]+$/.test(path) ? path : null; | ||
| } | ||
|
|
||
| /** | ||
| * Adds the URL and the repository from browser-specs to an entry from specs.json | ||
| * | ||
| * @param {object} entry | ||
| * @returns {object | null} null when browser-specs doesn't know the shortname | ||
| */ | ||
| export function resolveSpec(entry) { | ||
| const found = byShortname.get(entry.shortname) ?? byFormerName.get(entry.shortname); | ||
| if (!found) return null; | ||
| if (found.shortname !== entry.shortname) { | ||
| logger.warn(`[specs] "${entry.shortname}" is a former shortname of "${found.shortname}" in browser-specs. Please rename it in specs.json`); | ||
| } | ||
| return { | ||
| ...entry, | ||
| url: found.nightly?.url ?? null, | ||
| repo: githubRepo(found.nightly?.repository), | ||
| }; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to filter this way, vs. referencing
resolvedSpecs?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolvedSpecsis a subset ofspecs(with additional properties). So if for some reasons, a spec listed inspecs.jsonis dropped out from browser-specs, it will no longer be inresolvedSpecsand hence, will not be processed.Filtering
specswill ensure we keep the existing data available untilspecs.jsonis cleaned up.index.jswill report an error (l.130) in such case and a manual cleanup is expected.