GLab命令行工具

Summary: Author: 张亚飞 | Read Time: 1 minute read | Published: 2022-09-30
Filed under Categories: LinuxTags: Note,

Gitlab 通过命令行提交 merge_request

经常在 gitlab 后台提交 merge_request 比较繁琐,研究使用 cli 提交办法

使用 gitlab 官方的文档,提交 merge_request 不生效:

$ git push -o merge_request.create -o merge_request.target=release-test origin k8s
Everything up-to-date
$ git push -o merge_request.create -o merge_request.target=release-test --set-upstream origin k8s
Everything up-to-date

如果没有需要 commit 的提交,会提示 Everything up-to-date,解决办法有两个:

GLab 通过命令行提交 merge_request

glabgitlab 官方提供的 cli 命令行工具,可以解决 merge_request 问题

项目地址: glab

安装配置

安装

$ brew install glab
$ glab --version
glab version 1.30.0 (2023-05-19)

首次安装需登录 gitlab 配置授权,详细过程如下:

$ glab auth login
? What GitLab instance do you want to log into? GitLab Self-hosted Instance
? GitLab hostname: git.baijiashilian.com
? API hostname: git.baijiashilian.com
- Logging into git.baijiashilian.com
? How would you like to login? Token

Tip: you can generate a Personal Access Token here https://git.baijiashilian.com/-/profile/personal_access_tokens
The minimum required scopes are 'api' and 'write_repository'.
? Paste your authentication token: ********************
? Choose default git protocol HTTPS
? Authenticate Git with your GitLab credentials? Yes
? Choose host API protocol HTTPS
- glab config set -h git.baijiashilian.com git_protocol https
✓ Configured git protocol
- glab config set -h git.baijiashilian.com api_protocol https
✓ Configured API protocol
✓ Logged in as zhangyafei

使用 glab 创建 merge_request:

默认将当前所在分支 merge_requestmaster 主分支

$ glab mr create
? Choose a template Open a blank merge request
? Title: k8s部署配置
? Description <Received>
? What's next? Submit

Creating merge request for k8s into master in LLL/brtc/webserver/vdemo

!25 k8s部署配置 (k8s)
 https://git.baijiashilian.com/LLL/brtc/webserver/vdemo/-/merge_requests/25

创建一个提交,并指定 reviewer

$ glab mr create --target-branch=release-test --reviewer=caiyili

暂不支持 git pushmerge_request.merge_when_pipeline_succeeds:

Add the ability to set the “merge when pipeline succeeds” flag

参考文档


Comments

Cor-Ethan, the beverage → www.iirii.com