fix(branch): URL-encode branch name in unprotect, add +unprotect to Skill
- shortcuts/branch/branch.go: unprotect 使用 url.PathEscape 编码分支名(含 / 的分支名) - skills/gitlink-branch/SKILL.md: 新增 +unprotect 命令(参数、示例、Workflow) - skills/gitlink-branch/examples/branch-workflow.md: 注意事项补 +unprotect 说明 - 注意:含 / 的分支名 unprotect 受限于 Gitea API 路由,需通过 Web 操作
This commit is contained in:
parent
a3b710268e
commit
6ff7384f99
|
|
@ -110,7 +110,7 @@ func Shortcuts() []*common.Shortcut {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
name, _ := ctx.RequireArg("name")
|
name, _ := ctx.RequireArg("name")
|
||||||
env, err := ctx.CallAPI("DELETE", fmt.Sprintf("%s/protected_branches/%s", ctx.RepoPath(), name), nil)
|
env, err := ctx.CallAPI("DELETE", fmt.Sprintf("%s/protected_branches/%s", ctx.RepoPath(), url.PathEscape(name)), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ metadata:
|
||||||
| `branch +create` | 创建新分支 | ⚠️ Write Operation |
|
| `branch +create` | 创建新分支 | ⚠️ Write Operation |
|
||||||
| `branch +delete` | 删除分支 | 🔴 Destructive Operation |
|
| `branch +delete` | 删除分支 | 🔴 Destructive Operation |
|
||||||
| `branch +protect` | 设置分支保护规则 | ⚠️ Write Operation |
|
| `branch +protect` | 设置分支保护规则 | ⚠️ Write Operation |
|
||||||
|
| `branch +unprotect` | 移除分支保护规则 | ⚠️ Write Operation |
|
||||||
|
|
||||||
## 参数参考
|
## 参数参考
|
||||||
|
|
||||||
|
|
@ -69,6 +70,16 @@ metadata:
|
||||||
| `--format` | 否 | 输出格式:`json`/`table`/`yaml` |
|
| `--format` | 否 | 输出格式:`json`/`table`/`yaml` |
|
||||||
| `--debug` | 否 | 启用调试输出 |
|
| `--debug` | 否 | 启用调试输出 |
|
||||||
|
|
||||||
|
### branch +unprotect
|
||||||
|
|
||||||
|
| 参数 | 必填 | 说明 |
|
||||||
|
|------|------|------|
|
||||||
|
| `--name, -n` | 是 | 要移除保护的分支名称 |
|
||||||
|
| `--owner` | 是* | 仓库所有者(可从 git remote 自动推断) |
|
||||||
|
| `--repo` | 是* | 仓库名称(可从 git remote 自动推断) |
|
||||||
|
| `--format` | 否 | 输出格式:`json`/`table`/`yaml` |
|
||||||
|
| `--debug` | 否 | 启用调试输出 |
|
||||||
|
|
||||||
> *如果在 GitLink 仓库目录下执行,`--owner` 和 `--repo` 可自动推断。
|
> *如果在 GitLink 仓库目录下执行,`--owner` 和 `--repo` 可自动推断。
|
||||||
|
|
||||||
## 使用示例
|
## 使用示例
|
||||||
|
|
@ -103,6 +114,9 @@ gitlink-cli branch +protect --name main
|
||||||
|
|
||||||
# 指定仓库保护分支
|
# 指定仓库保护分支
|
||||||
gitlink-cli branch +protect --name main --owner someone --repo myrepo
|
gitlink-cli branch +protect --name main --owner someone --repo myrepo
|
||||||
|
|
||||||
|
# 移除分支保护(仅简单分支名,含 / 的路径需通过 Web 操作)
|
||||||
|
gitlink-cli branch +unprotect --name main
|
||||||
```
|
```
|
||||||
|
|
||||||
## Workflow 注意事项
|
## Workflow 注意事项
|
||||||
|
|
@ -134,6 +148,17 @@ gitlink-cli branch +protect --name main --owner someone --repo myrepo
|
||||||
2. 执行 `branch +protect --name <name>`。
|
2. 执行 `branch +protect --name <name>`。
|
||||||
3. 输出设置结果。
|
3. 输出设置结果。
|
||||||
|
|
||||||
|
### branch +unprotect(Write Operation)
|
||||||
|
|
||||||
|
> [!CAUTION]
|
||||||
|
> This is a **Write Operation** — confirm user intent.
|
||||||
|
|
||||||
|
1. 确认用户希望移除保护的分支名称。
|
||||||
|
2. 执行 `branch +unprotect --name <name>`。
|
||||||
|
3. 输出结果。
|
||||||
|
|
||||||
|
> **注意:** 含 `/` 的分支名(如 `feature/my-branch`)可能无法通过 CLI 解除保护(受限于 Gitea API),需通过 Web 页面操作。
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
- [gitlink-shared](../gitlink-shared/SKILL.md) — 认证、全局参数、安全规则
|
- [gitlink-shared](../gitlink-shared/SKILL.md) — 认证、全局参数、安全规则
|
||||||
|
|
|
||||||
|
|
@ -65,4 +65,6 @@ gitlink-cli branch +delete --name feature/old-login
|
||||||
|
|
||||||
- `branch +delete` 是 **Destructive Operation**,操作前请确认分支内容已合并或无保留价值
|
- `branch +delete` 是 **Destructive Operation**,操作前请确认分支内容已合并或无保留价值
|
||||||
- `branch +protect` 会对分支施加保护规则,影响后续的推送和合并流程
|
- `branch +protect` 会对分支施加保护规则,影响后续的推送和合并流程
|
||||||
|
- `branch +unprotect` 仅支持简单分支名(如 `main`),含 `/` 的路径需通过 Web 页面操作
|
||||||
|
- 建议使用 `branch +list` 先查看分支状态,再执行写入/删除操作
|
||||||
- 建议使用 `branch +list` 先查看分支状态,再执行写入/删除操作
|
- 建议使用 `branch +list` 先查看分支状态,再执行写入/删除操作
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue