Gerrit的ssh命令的query用法

Gerrit的gerrit query命令就是要查询Gerrit的changes数据库。

默认,查询结果是根据changes的更新时间,由近及远排序。

对于有多个patch set的change,默认查询结果只包含最后的patch set。

如果查询结果有很大,则默认只返回有限个查询结果,可以设置limit:参数指定查询结果包含的changes数量。


1. gerrit query命令用法:

  1. ssh -p <port> <host> gerrit query

  2. [--format {TEXT | JSON}]

  3. [--current-patch-set]

  4. [--patch-sets | --all-approvals]

  5. [--files]

  6. [--comments]

  7. [--commit-message]

  8. [--dependencies]

  9. [--submit-records]

  10. [--all-reviewers]

  11. [--start <n> | -S <n>]

  12. <query>

  13. [limit:<n>]

常见选项说明:

  • --format=TEXT,默认
  • --format=JSON
  • --current-patch-set,给出当前patch set的信息
  • --patch-sets,给出所有patch set的信息
  • --commit-message,给出change的完整commit message
  • --all-reviewers,给出所有reviewer的name和email

<query>说明:

  • status:open等价于status:pending, is:open, is:pending
  • owner:self等价于is:owner
  • reviewer:self等价于is:reviewer
  • project:buto/bba或p:buto/ba
  • projects:bb
  • branch:develop或branch:refs/heads/develop
  • change:2311176或change:I03369813660369e983b56dcabe44cb48839be4de0
  • commit:4e8ea8d43ab22273e49493484e1e7316f88cd54e3
  • ref:refs/changes/76/2311476/1
  • message:my_commit_message
  • is:visible
  • label:Code-Review=2或label:Code-Review=+2或label:Code-Review+2
  • label:Verified+1

举个例子:查询某个提交的信息, 可以得到这次提交的,项目名字,owner, uploader,commit 信息,更新时间,code-reviewer,appover等

  ssh -p 29418 gerrit.ericsson.se gerrit query --format=text change:6075294 --current-patch-set  格式如下(主要信息删除了)

change 
  project: 
  branch: master
  id: 
  number: 6075294
  subject: 
  owner:
    name: 
    email: 
    username: 
  url: https://gerrit./6075294
  commitMessage: 
                 
                 
                 
                 
                 
                 
  createdOn: 2019-09-23 09:38:46 CEST
  lastUpdated: 2019-11-11 08:14:25 CET
  open: false
  status: MERGED
  currentPatchSet:
    number: 18
    revision: 
    parents:
 []
    ref: refs/changes/94/6075294/18
    uploader:
      name: 
      email: 
      username: 
    createdOn: 2019-11-11 08:14:25 CET
    author:
      name: 
      email: 
      username: 
    isDraft: false
    kind: TRIVIAL_REBASE
    approvals:
      type: Commit-Msg
      description: Commit-Msg
      value: 1
      grantedOn: 2019-11-05 09:29:25 CET
      by:
        name: 
        email: 
        username: 
    approvals:
      type: Verified
      description: Verified
      value: 1
      grantedOn: 2019-11-07 06:48:50 CET
      by:
        name: 
        username: 
    approvals:
      type: Code-Review
      description: Code-Review
      value: 1
      grantedOn: 2019-11-07 10:05:14 CET
      by:
        name:  
        email: .@.com
        username: 
    approvals:
      type: Code-Review
      description: Code-Review
      value: 1
      grantedOn: 2019-11-11 08:08:44 CET
      by:
        name:  
        email: .@.com
        username: 
    approvals:
      type: Code-Review
      description: Code-Review
      value: 2
      grantedOn: 2019-11-11 08:09:17 CET
      by:
        name:   
        email: 
        username: 
    approvals:
      type: SUBM
      value: 1
      grantedOn: 2019-11-11 08:14:25 CET
      by:
        name:  
        email: .@.com
        username: 
    sizeInsertions: 43
    sizeDeletions: -5

type: stats
rowCount: 1
runTimeMilliseconds: 5
moreChanges: false

posted @ 2020-11-20 15:54  枫奇丶宛南  阅读(497)  评论(0编辑  收藏  举报