cnb-rs label clone
cnb-rs label clone <source-repo> [-f]从源仓库复制全部 labels 到当前仓库。对齐 gh label clone。
工作流程
list_labels(source)拉取源仓库全部 labels(最多 100,CNB API 单页上限)list_labels(target)拉取当前仓库现有 labels,建立去重 set- 逐个处理 source label:
- 在 target 不存在 →
post_label创建 - 在 target 已存在 且未传
--force→ 跳过 - 在 target 已存在 且
--force→patch_label覆盖 color / description
- 在 target 不存在 →
- 汇总报告 created / updated / skipped / failed 四个计数 + 失败明细
参数
<source-repo>: 源仓库路径(位置参数,必填;格式:group/repo或group/sub-group/repo)
选项
-f, --force: 已存在的同名 label 改用patch_label覆盖;不传时默认 skip
继承的全局选项:
--repo <REPO>: 指定当前(目标)仓库路径;默认从 git remote 推断或cnb.defaultRepo读取--json: 以 JSON 格式输出汇总报告--domain <DOMAIN>: 指定目标域名(默认:cnb.cool)
示例
bash
# 从 source 仓库克隆全部 labels 到当前仓库(已存在的跳过)
$ cnb-rs label clone group/source-repo
从 group/source-repo 拉取到 22 个标签,准备 clone 到 wwvo/cnb-rs/cnb-rs
✓ clone 完成:创建 22,更新 0,跳过 0,失败 0
# 第二次跑(同名全部 skip)
$ cnb-rs label clone group/source-repo
✓ clone 完成:创建 0,更新 0,跳过 22,失败 0
# 加 --force 让已存在的 label 也用 source 的 color/description 覆盖
$ cnb-rs label clone group/source-repo --force
✓ clone 完成:创建 0,更新 22,跳过 0,失败 0
# 源仓库与目标相同 → friendly bail
$ cnb-rs label clone wwvo/cnb-rs/cnb-rs
错误: 源仓库与目标仓库相同(wwvo/cnb-rs/cnb-rs),无需 clone
# JSON 输出供脚本消费
$ cnb-rs label clone group/source-repo --json
{
"source": "group/source-repo",
"target": "wwvo/cnb-rs/cnb-rs",
"total": 22,
"created": 22,
"updated": 0,
"skipped": 0,
"failed": 0,
"failed_details": []
}与 gh 对照
| 能力 | gh label clone | cnb-rs label clone |
|---|---|---|
| 跨仓库复制 labels | ✓ | ✓ 完全对齐 |
--force 覆盖 | ✓ | ✓ |
| 汇总报告 | 仅文本 | ✓ + --json 结构化输出 |
| 失败明细 | 文本 | ✓ + JSON failed_details 数组 |
| 源/目标相同检查 | 无 | ✓ friendly bail |