logo
0
0
Login
fix: 优化错误信息输出

git-cnb, 一个 cnb 专属的 Git 命令行扩展工具, 可以使用 git 命令行的方式在终端快捷查看 cnb 的信息,比如仓库,用户,issue,pr,release 等等。

安装

二进制安装 [荐]

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:r repo-pr:r repo-code:rw repo-basic-info:r account-profile:r

支持的功能

$ git cnb -h Available Commands: commit Manage commits help Help about any command info Print information of this repo issue Manage issue pull Manage pull requests release Manage releases stars Print star trend info of this repo stats Print stats information of this repo version Print the version number of git-cnb

一些使用示例

NOTE: CNB OpenAPI 更新可能有延迟,请以实际情况为准

获取仓库统计信息

git cnb stats

查看仓库的 stars 趋势

git cnb stars

列出当前仓库跟你有关的 issue (同时查看本组织下 feedback 跟你有关的 issue)

git cnb issue list

列出当前仓库跟你有关的 pr

git cnb pull list

push完代码后一键创建 pr

git cnb pull create

统计并且清理当前仓库下 release asset

git cnb release asset-stats

git cnb release asset-clean --keep-days=1

统计并且清理当前仓库下 commits asset

git cnb commit asset-stats

git cnb commit asset-clean --keep-num=1