Repository navigation
feat(marketplace): resolveSource 报告索引跟随的仓库和分支,可按提交固定地址绕过 raw 缓存;GitHub 新增 latestCommit 和 listReleases - #173
Merged
Conversation
…b 新增 latestCommit 和 listReleases raw.githubusercontent.com 对分支地址缓存 5 分钟,Store 合入新版本后宿主还会读到旧索引。 resolveSource 对托管在 GitHub 的索引返回 revision(仓库和 ref),宿主用新的匿名操作 github latestCommit 查到当前提交后带 commit 再调一次,得到 pinned(同一批文件在该提交上 的地址)。indexURL 仍是来源身份。listReleases 给插件详情的更新日志用,匿名读取、去掉草稿、 按发布时间倒序。
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
背景
Store 合入插件新版本后,桌面端要等好几分钟才看到更新。原因之一是 raw.githubusercontent.com 对分支地址(
…/HEAD/lithe-plugin-index.json)缓存max-age=300,加随机查询参数或Cache-Control: no-cache都还是命中缓存。按提交 SHA 的地址不会命中旧缓存(实测X-Cache: MISS,内容是最新的)。另外,插件详情要加「更新日志」页签,需要读插件仓库的 GitHub Releases。
改动
plugins.marketplace.resolveSourcerevision: { repository: { owner, name }, ref } | null:索引托管在 GitHub 上且地址不带查询参数时,给出地址跟随的 ref(HEAD、路径第一段,或refs/heads/<name>、refs/tags/<name>)。其他来源、已经指向完整提交的地址为 null。commit(完整 SHA-1 或 SHA-256,否则plugin.source.commitInvalid)。带上后输出多出pinned: { commit, indexURL, recommendationsURL } | null,即同一批文件在该提交上的地址。indexURL不变,仍是来源身份(信任记录、自动更新的来源比对都用它)。宿主查询或固定下载失败时退回原地址。/时,只有写成refs/heads/<name>才能固定;其他写法查询失败,宿主会退回原地址。GitHub(
github.requestPlan/github.normalizeResponse)latestCommitGET /repos/{owner}/{name}/commits?sha={ref}&per_page=1,匿名{ sha },完整小写 SHAlistReleasesGET /repos/{owner}/{name}/releases?per_page=20,匿名[{ tagName, name, body, publishedAt, prerelease, url }],去掉草稿,按发布时间倒序ref字段,拒绝空白、..、开头的-和~ ^ : ? * [ \。requiresAuthentication: false,未登录也能用。契约与文档
shared/plugins/contract/v1/fixtures/marketplace/source-urls.json:已有用例补上revision,新增 5 个带commit的成功用例和 1 个plugin.source.commitInvalid用例(共 17 个)。reference/domains/marketplace.md(中英)、rust/contracts/github.md、rust/contracts/rust-core-api.md、插件协议更新记录。验证
cargo test -p lithe-core --lib -- tests::github tests::marketplace_plugins:31 个通过。cargo clippy -p lithe-github -p lithe-plugin-marketplace -p lithe-core --all-targets -- -D warnings、cargo fmt --all -- --check。node scripts/rust-core/verify-platform-tests.mjs、scripts/rust-core/verify-rust-core-comments.sh、node shared/plugins/scripts/verify-docs.mjs。Lithe-IDEA/Lithe-store的HEAD提交,再取该提交的lithe-plugin-index.json,返回X-Cache: MISS且包含刚合入的版本。桌面端接入在 1lck/Lithe-IDEA 的后续 Draft PR。