cnb-rs repo edit
cnb-rs repo edit [<repo>] [flags]编辑仓库信息。可更新描述、许可证、站点 URL 和主题标签。
不指定仓库路径时,使用当前 Git 目录对应的仓库。 至少需要指定一个要修改的字段,否则命令会报错。
选项
[<repo>]:仓库路径(如org/repo),可选-d, --description <TEXT>:仓库描述-l, --license <LICENSE>:开源许可证-s, --site <URL>:仓库站点 URL-t, --topics <T1,T2,...>:全量替换 topics(逗号分隔);与--add-topic/--remove-topic互斥--add-topic <TOPIC>:增量添加 topic(可重复或逗号分隔);实现内部先 GET 现有 topics 再 PATCH。与--topics互斥--remove-topic <TOPIC>:增量移除 topic(可重复或逗号分隔)。与--topics互斥
继承的全局选项:
--repo <REPO>: 指定仓库路径(格式:group/repo)--domain <DOMAIN>: 指定目标域名(默认:cnb.cool)
示例
bash
# 更新当前仓库的描述
$ cnb-rs repo edit --description "新的描述"
✓ 仓库信息已更新 (org/repo)
# 全量替换 topics
$ cnb-rs repo edit org/repo --license MIT --topics "cli,rust,tool"
✓ 仓库信息已更新 (org/repo)
# 增量添加 topic(不影响现有 topics)
$ cnb-rs repo edit --add-topic cli
✓ 仓库信息已更新 (org/repo)
# 增量添加多个 + 同时移除一个
$ cnb-rs repo edit --add-topic rust,tool --remove-topic deprecated
# 同时更新描述和增量 topic
$ cnb-rs repo edit -d "new desc" --add-topic alpha
# 互斥校验(clap 拒绝)
$ cnb-rs repo edit --topics a --add-topic b
error: the argument '--topics <TOPICS>' cannot be used with '--add-topic <TOPIC>'API
| 场景 | API | 方法 |
|---|---|---|
| 仅全量更新、不含 add/remove-topic | ${CNB_API_ENDPOINT}/{repo} | PATCH |
含 --add-topic 或 --remove-topic | 先 GET ${CNB_API_ENDPOINT}/{repo} 拿现有 topics,再 PATCH 同一 URL | GET + PATCH |
CNB 只有全量 PATCH topics: Vec<String>,所以增量 flag 需要本地 read-modify-write。合并语义:先加后删(同时出现在 add 和 remove 里的 topic 最终被删),结果去重并按 BTreeSet 排序。
API 详情(OpenAPI:UpdateRepo):
- 权限要求:
repo-manage:rw - 请求体:
json
{
"description": "string",
"license": "string",
"site": "string",
"topics": ["string"]
}与 issue/pr edit 设计对齐
--add-X / --remove-X 增量 flag 与 issue edit 的 --add-label / --add-assignee 等一致;与全量 flag 互斥,不允许同时详细赋值。