git-cnb, 一个 cnb 专属的 Git 命令行扩展工具, 可以使用 git 命令行的方式在终端快捷查看 cnb 的信息,比如仓库,用户,issue,pr,release 等等。
完全由 CNB CodeWiki 智能生成, 准确度高达 99.7%
二进制安装 [荐]
curl https://cnb.cool/looc/git-cnb/-/git/raw/main/install.sh -sSfL | sh
使用 golang 安装
go install cnb.cool/looc/git-cnb@latest
作为 git 的一个扩展子命令行工具来使用。
NOTE: 由于需要调用 CNB 的 openapi 获取相关信息,所以需要使用环境变量来配置 CNB 的 Token, token 的权限取决于使用到的功能,可按需来配置 token 权限。
$ export CNB_TOKEN="... your token ..."
如果你同时需要操作多个域名不同的 CNB, 可以为每个域名配置不同的 CNB_TOKEN,规则为 CNB_TOKEN_{domain-without-dot}(环境变量不支持., 这里使用域名去掉.的后缀来区分,比如
$ export CNB_TOKEN_cnbcool=".. your token ..." #cnb.cool $ export CNB_TOKEN_cnbdev=".. your token ..." #cnb.dev
TOKEN至少需要如下权限:
repo-notes:rw
repo-pr:rw
repo-code:rw
repo-basic-info:r
account-profile:r
group-manage:rw
你也可以再云原生构建中使用 git-cnb, 默认使用云原生构建的环境变量 CNB_TOKEN, 如果默认的 TOKEN 权限不满足你的需求,可以手动指定,比如使用 CNB_TOKEN_cnbcool。
stages: - name: build jobs: - name: 使用 git-cnb image: docker.cnb.cool/looc/git-cnb:latest script: git-cnb -h
$ git-cnb -h
Available Commands:
build 管理仓库构建
chat 用自然语言与 CNB OpenAPI 交互
commit 管理 Commit 相关操作
completion Generate the autocompletion script for the specified shell
download 下载仓库文件
git-settings 管理仓库设置
groups 管理组织
help Help about any command
info 显示仓库详细信息
issues 管理仓库 Issue
knowledges 管理仓库知识库
pull 管理 Pull Request
release 管理仓库 Release
stars 绘制仓库 Star 趋势图
stats 显示仓库统计面板
version 打印 git-cnb 的版本号
workspace 管理云原生工作空间
Flags:
--domain string domain, eg: cnb.cool, default: cnb.cool
-h, --help help for git-cnb
--repo string repo name, eg: looc/git-cnb
详细的使用方法参见这里
如果你是在一个 git 目录下使用,git-cnb 会自动解析当前仓库的信息,获取到 api 的 domain 以及 reponame。
你也可以手动指定 domain 和 reponame, 比如: git-cnb --domain=cnb.cool --repo=looc/git-cnb stars
git-cnb 也提供了一些 cnb 插件,你可以使用插件来快速完成一些复杂的任务。