介绍
# GitLab Manager
此技能允许通过 API 与 GitLab.com 进行交互。
## 前置条件
- **GITLAB_TOKEN**:必须在环境中设置一个具有 `api` 权限的个人访问令牌。
## 用法
使用提供的 Node.js 脚本与 GitLab 进行交互。
### 脚本位置 `scripts/gitlab_api.js`
### 命令
#### 1. 创建仓库 在 GitLab 中创建一个新项目。 ```bash ./scripts/gitlab_api.js create_repo "<name>" "<description>" "<visibility>" # Visibility: private (default), public, internal ```
#### 2. 列出合并请求 列出特定项目的 MR。 ```bash ./scripts/gitlab_api.js list_mrs "<project_path>" "[state]" # Project path: e.g., "jorgermp/my-repo" (will be URL encoded automatically) # State: opened (default), closed, merged, all ```
#### 3. 评论合并请求 向特定的 MR 添加评论(说明)。适用于代码审查。 ```bash ./scripts/gitlab_api.js comment_mr "<project_path>" <mr_iid> "<comment_body>" ```
#### 4. 创建议题 打开一个新议题。 ```bash ./scripts/gitlab_api.js create_issue "<project_path>" "<title>" "<description>" ```
## 示例
**创建一个私有仓库:** ```bash GITLAB_TOKEN=... ./scripts/gitlab_api.js create_repo "new-tool" "A cool new tool" "private" ```
**审查一个 MR:** ```bash # First list to find ID GITLAB_TOKEN=... ./scripts/gitlab_api.js list_mrs "jorgermp/my-tool" "opened" # Then comment GITLAB_TOKEN=... ./scripts/gitlab_api.js comment_mr "jorgermp/my-tool" 1 "Great work, but check indentation." ```