Skip to content

[任务]: MindSpore 使用自建LFS 并支持github平台-的开发实现-BigFiles部分 - #84

Closed
fly333sky wants to merge 2 commits into
masterfrom
issue-179-from-master
Closed

fly333sky wants to merge 2 commits into
masterfrom
issue-179-from-master

Conversation

@fly333sky

Copy link
Copy Markdown

背景

[任务]: MindSpore 使用自建LFS 并支持github平台(BigFiles)· 开发流水线 · 开发预览阶段(代码已推 + 预览已部署 + UT 已补;门禁/对抗由 PR CI 异步跑)

改动内容

fix(BigFiles/lfs-website): 修复 GitHub 仓库外链错链 + 补齐 server 包新增函数单测覆盖

本轮针对上一轮预览核验的 4 条 FAIL 逐项修复,无设计变更、无环境改动。

一、修复 GitHub 仓库外链错链(lfs-website 前端,根因在后端缺稳定平台字段)

问题:TheDetail.vue 的 repoPlatform 从「当前页/筛选后的 filesList」推断平台
(filesList.value.find(f=>f.platform)?.platform),导致:

  1. 新 GitHub 仓 lfs_obj 无记录时 filesList=[] → repoPlatform='' → 外链错指
    atomgit.com/{owner}/{repo};
  2. 同一仓库切换平台筛选器时,filesList 变化 → 外链域名跟着跳变。

修法(与设计文档 2.3.2 一致,不新增接口、不改路由/表):

  • 后端 server.go 的 /object/list 响应新增 platform 字段,值 =
    auth.ResolvePlatform(owner)(owner 解析,与文件筛选器无关,文件列表为空也正确)。
  • 前端 repoPlatform 由 computed(filesList) 改为 ref,取自响应 res.platform;
    外链改用纯函数 buildRepoUrl(platform, ownerRepo) 生成。
  • 结果:GitHub 仓外链恒为 https://github.com/{owner}/{repo},跨筛选器稳定。

改动文件:

  • BigFiles server/server.go:List 传 repoPlatform,buildListResponse 增 Platform 字段。
  • BigFiles server/server_test.go:TestBuildListResponse 适配新签名并断言 platform。
  • lfs-website src/utils/repo.ts(新):buildRepoUrl 纯函数。
  • lfs-website src/views/detail/TheDetail.vue:repoPlatform→ref(API),repoUrl 走 buildRepoUrl,路由切换时重置。
  • lfs-website src/@types/type-repo.ts:补 RepoFilesListResponseT(含 platform)。

二、补齐 server 包新增/变更函数单测(覆盖率 ≥80%,全绿)

针对上一轮报红的 3 项覆盖率缺口:

函数 上轮 本轮
tokenForPlatform (server.go:631) 0.0% 100%
authorizedFn (server.go:244) 50.0% 100%
getLfsFiles (server.go:519) 0.0% 87.5%
countLfsFiles (server.go:539) 0.0% 85.7%

新增 UT 文件(均在 BigFiles 子仓,照既有 testify + table-driven 风格):

  • server/platform_test.go:
    • TestTokenForPlatform — github/gitcode/default 三分支(含未知平台兜底 gitee)。
    • TestAuthorizedFn_FallbackNilMap — IsAuthorizedByPlatform=nil 走 isAuthorized 兜底(原 50% 缺口)。
    • TestAuthorizedFn_FallbackUnknownPlatform — map 已配但平台未命中走兜底。
    • TestAuthorizedFn_PlatformHit — 命中平台用平台专属 authorizer。
  • server/listfiles_test.go:
    • TestGetLfsFiles_PlatformFilter / TestCountLfsFiles_PlatformFilter — 用 SQLite in-memory(单连接)
      插入 github/gitee/exist=0 行,钉死 platform==="" 不加过滤、platform==="github" 加过滤
      两条分支(回归保护:防止再次破坏前端「全部」筛选)。
    • 表用 SQLite 原生 DDL(绕开 LfsObj 上 MySQL 专有 ON UPDATE 子句),db.Db 存/恢复。

lfs-website UT(vitest,按约定不在 runner 上跑,预览 pod 内执行):

  • tests/repo.test.ts — buildRepoUrl:github→github.com;gitee/gitcode/''→atomgit.com;跨筛选器稳定回归用例。

三、依赖

  • BigFiles go.mod 增 gorm.io/driver/sqlite v1.6.0(CGO,仅 server/listfiles_test.go import,
    go build ./main.go 不编译测试文件,生产镜像二进制不受影响;runner 有 gcc+cgo)。
  • gorm 维持 v1.31.1,mysql 驱动维持 v1.6.0,无生产依赖版本变动。

四、验证

相关 Issue

resolve https://github.com/opensourceways/backlog/issues/179

AI 使用声明

当前 PR 是否有 AI 参与:

@opensourceways-bot

Copy link
Copy Markdown

Welcome To opensourceways Community

Hey @fly333sky , thanks for your contribution to the community.

Bot Usage Manual

I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands.

Contact Guide

If you have any questions, please contact the SIG: infratructure ,
and any of the maintainers: @GeorgeCao-hw, @TangJia025, @pkking, @zhongjun2 ,
and any of the committers: @Goalina, @Zherphy, @tfhddd .

@opensourceways-bot

Copy link
Copy Markdown

CLA Signature Pass

fly333sky, thanks for your pull request. All authors of the commits have signed the CLA. 👍

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedgorm.io/​driver/​sqlite@​v1.6.0100100100100100

View full report

@opensourceways-bot

Copy link
Copy Markdown
检查项 状态
敏感信息扫描 ❌
安全编码扫描 ❌
漏洞扫描 ❌
Check代码检查 ❌
开源license合规扫描 ✅
UT测试覆盖率 ❌
开发阶段设计文档检查 ❌
流水线链接 点击跳转查看日志

@Zherphy Zherphy closed this Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants