Skip to main content

Gerrit Command Line Interface

Project description

Gerrit 命令行接口。

LICENSE

安装

pip install python-gerrit-cli

使用方法

在使用之前需要先设置用户名和HTTP密码,这些信息存储在~/gerrit.rc。这一步只需要做一次。

gerritcli server add <name> <host> <username> <password>

可以添加多组信息(不同服务器,或同一服务器的不同用户),默认使用添加的第一组信息。gerritcli server default <name>修改默认值,也可以使用全局选项-s <name>指定服务器。

示例1:查看帮助信息

主命令和子命令都支持-h选项。

$ gerritcli -h
usage: gerritcli [-h] [-s SERVER] [--debug] command ...

positional arguments:
  command     command usage
    server    add/remove/list gerrit server info
    version   show gerrit server version
    project   project command
    account   account command help
    change    change command help
    group     group command
    patch     patch command help

optional arguments:
  -h, --help  show this help message and exit
  -s SERVER   specify gerrit server. If not specified, the default value is used
  --debug     enable debug

$ gerritcli change -h
usage: gerritcli change [-h] {search,get,create,delete} ...

positional arguments:
  {search,get,create,delete}
                        change command help
    search              Queries changes visible to the caller.
    get                 get change
    create              create change
    delete              delete change

optional arguments:
  -h, --help            show this help message and exit

示例2:查询服务器版本

gerritcli version

示例3:查询修改

查询自己还没有合并的修改。默认以表格的形式输出。关于搜索指令is:open+is:owner的更多信息,可以参考gerrit文档,Searching Changes

gerritcli change search 'is:open+is:owner'

示例4:指定输出格式

使用选项--format指定输出的格式,支持tablecsvjson。例如查询分支xxxxx已合并的修改,并保存到文件。这样可以Excel等工具打开,进行二次分析。

gerritcli change search --format csv 'branch:xxxxx+is:merged' > merged_cl.csv

示例5:指定表头

tablecsv格式默认只会打印numberowner_namesubjectstatussubmitter_namecreatedsubmitted字段,json格式会打印所有字段。可以使用--header选项打印指定字段。例如只打印numbersubject。支持的字段请参考json格式的输出。

gerritcli change search 'is:open+is:owner' --header 'number,subject'

示例6:列出所有的仓库

gerritcli project list

示例6:搜索活跃的账号

gerritcli account search 'is:active'

示例7:下载补丁

gerritcli patch <id>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-gerrit-cli-1.0.6.tar.gz (16.1 kB view hashes)

Uploaded Source

Built Distribution

python_gerrit_cli-1.0.6-py3-none-any.whl (17.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page