Repository navigation
fix(cli,release): 修 8 条 issue(#125-#132):注入面/参数透传/超时分层/latest 纪律/子命令守卫 - #133
Merged
Merged
Conversation
- #125 release.yml 脚本注入面:${{ github.ref_name }} 全部改 env 注入 $TAG, run: 脚本内一律取 "$TAG";回调 JSON 改 jq --arg 构造。tag 名可含引号/分号/ 美元符且 v* tag 无 ruleset 保护 ⇒ 直插是持 contents+packages write 与 PB_BOT_TOKEN 的评审外代码执行面。 - #126 docker-entrypoint 参数透传:末行硬编码改 exec "$@"(无参补默认起服、 首参为旗标时补 ./server、子命令补 ./ 前缀),Dockerfile CMD 与 docker run <参数> 真生效;补 scripts/docker-entrypoint_test.sh 四条判据。 - #127 pb put -t 与文件互斥:判据放 parsePutFlags(put/import 共用一处拦), 原实现文本分支先 return ⇒ 文件被静默丢弃还返回成功;补复现测试。 - #128 pb 超时分层:查询类 30s(doctor 深度检查等)/ 上传类 30min(put 直传、 多文件合并、存储迁移、import-local 服务端整文件拷贝),不再共用 30 分钟; 补 timeout_test.go 钉默认值与走向。 - #129 pb url -p 缺值报用法错(退出码 2),rm 旗标形状参数与 ls 多余参数同拦; 补 flag_guard 矩阵(url/ls/rm 一并过)。 - #130 server 子命令白名单:flag.Parse 后位置参数非空且不在 backup/restore/db 白名单 ⇒ 打印用法 exit 2(拼错不再静默起服);自定义 flag.Usage 披露全部 离线子命令;补 main_test.go 子进程端到端判据。 - #131 latest 仅当全仓最高 semver:比较逻辑收进 scripts/image_tags.py (--check-latest + ls-remote 全量 tag + 离线自测),驱动 metadata-action enable= 与 Docker Hub 侧;gh release create 去掉 --latest。 - #132 db import 空库检查 fail-closed:HasTable 已为 true 时 Count 失败不是 「表不存在」,原实现把任意错误当空库 ⇒ 放行混库导入;补 GORM 回调注入 故障的复现测试。 门禁:go build/vet 通过,go test -count=1 ./... 与 go test -race ./... 全绿, gofmt -l . 为空,image_tags 自测与 docker-entrypoint 自测 OK,actionlint 无 新增告警(余下两条 HEAD 基线已有)。判据牙齿已逐条行为回退验证(回退 #127/ #129/#130/#132/#128/#131/#126 对应判据均转红后还原)。
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.
一次修掉本仓 8 条 issue(2026-11-14 审计批次),逐条对应:
Fixes #125
release.yml 脚本注入面:${{ github.ref_name }} 全部改为 env 注入
TAG,run: 脚本内一律取"$TAG";回调 dispatch 的 JSON 改jq --arg构造。v* tag 无 ruleset 保护 ⇒ 直插是持 contents+packages: write 与跨仓 PB_BOT_TOKEN 的评审外代码执行面。(仓库 ruleset 保护属设置项,需 admin 另行配置,不在本 PR 内)Fixes #126
docker-entrypoint.sh 末行硬编码改
exec "$@":无参补默认起服命令(与 Dockerfile CMD 同形,直跑行为不变)、首参为旗标时先补./server、子命令(pb doctor等)补./前缀。新增scripts/docker-entrypoint_test.sh四条判据(默认/自定义 --config/子命令/显式路径)。Fixes #127
pb put -t与文件同给时在parsePutFlags层报用法错(put 与 import 共用解析器,一处拦两处)——原实现文本分支先 return,文件被静默丢弃还返回成功。补复现测试(请求次数必须为 0)。Fixes #128
pb 超时分层:查询类 30s(
doReq,含 doctor 深度检查 GET /admin/diagnostics)/ 上传类 30min(doUploadReq:put 直传、多文件合并、存储迁移、import-local 服务端整文件拷贝)。原实现共用 30 分钟 ⇒ 黑洞地址下pb doctor挂半小时,而同命令降级检查是 30s(差 60 倍)。新增cmd/pb/timeout_test.go钉默认值与走向。Fixes #129
pb url -p缺值报用法错(退出码 2,不再把"-p"当取件码打成业务错 1);pb rm旗标形状参数、pb ls多余参数同拦;补 flag_guard 矩阵覆盖 url/ls/rm。Fixes #130
server 二进制:
flag.Parse后位置参数非空且不在backup/restore/db白名单 ⇒ 打印子命令用法并 exit 2(拼错子命令不再静默起服);自定义flag.Usage披露全部离线子命令与示例。新增cmd/server/main_test.go(子进程端到端验证真实退出码)。Fixes #131
latest 只在本次 tag 是全仓最高 semver 时才打:比较逻辑收进
scripts/image_tags.py(--check-latest+git ls-remote全量 tag + 离线自测 15 条判据),驱动 docker/metadata-action 的enable=与 Docker Hub 侧 tag 集;gh release create去掉--latest(交 GitHub 按 semver 自动判定)。旧线 hotfix tag 不再把 latest/Latest 指回旧版。Fixes #132
targetHasData的 Count 错误 fail-closed:HasTable已为 true 时 Count 失败只可能是权限/视图/驱动异常(原注释「表还没建」与上一步自相矛盾),原实现当空库 continue ⇒ 可放行db import --yes混库。补 GORM 回调注入故障的复现测试 + 三条正向判据(空库/空表/有数据)。门禁(本地 worktree 全跑)
go build ./...✅go vet ./...✅go test -count=1 ./...✅go test -race -count=1 ./...✅(cmd/pb、cmd/server 全绿)gofmt -l .为空 ✅(与 CI Gofmt 步同口径)python3 scripts/image_tags_selftest.py✅sh scripts/docker-entrypoint_test.sh✅actionlint .github/workflows/release.yml:余 2 条告警(line 27inputs.version、CLI 构建步 SC2086),与 HEAD 基线逐条相同,非本 PR 引入PB_*绑定,与基线等价(以 CI 为准)判据牙齿(逐条行为回退验证)
把每处修复单独回退、保留测试再跑,确认测试真能红后还原:
回退期间的 diff 已与提交内容做过字节级对账(IDENTICAL)后才收尾。