| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 1 | gerrit query |
| 2 | ============ |
| 3 | |
| 4 | NAME |
| 5 | ---- |
| 6 | gerrit query - Query the change database |
| 7 | |
| 8 | SYNOPSIS |
| 9 | -------- |
| 10 | [verse] |
| 11 | 'ssh' -p <port> <host> 'gerrit query' \ |
| 12 | [\--format {TEXT | JSON}] \ |
| 13 | [\--current-patch-set] \ |
| Martin Fick | db3be25 | 2010-09-15 13:59:54 -0600 | [diff] [blame] | 14 | [\--patch-sets|--all-approvals] \ |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 15 | [\--] \ |
| 16 | <query> \ |
| 17 | [limit:<n>] \ |
| 18 | [resume\_sortkey:<sortKey>] |
| 19 | |
| 20 | DESCRIPTION |
| 21 | ----------- |
| 22 | |
| 23 | Queries the change database and returns results describing changes |
| 24 | that match the input query. More recently updated changes appear |
| 25 | before older changes, which is the same order presented in the |
| 26 | web interface. |
| 27 | |
| 28 | A query may be limited on the number of results it returns with the |
| 29 | 'limit:' operator. If no limit is supplied an internal default |
| 30 | limit is used to prevent explosion of the result set. To obtain |
| 31 | results beyond the limit, the 'resume_sortkey:' operator can be used |
| 32 | to resume the query at the change that follows the last change of |
| 33 | the prior result set. |
| 34 | |
| 35 | Non-option arguments to this command are joined with spaces and then |
| 36 | parsed as a query. This simplifies calling conventions over SSH |
| 37 | by permitting operators to appear in different arguments without |
| 38 | multiple levels of quoting required. |
| 39 | |
| 40 | OPTIONS |
| 41 | ------- |
| 42 | \--current-patch-set:: |
| 43 | Include information about the current patch set in the results. |
| 44 | |
| 45 | \--patch-sets:: |
| 46 | Include information about all patch sets. If combined with |
| 47 | the \--current-patch-set flag then the current patch set |
| 48 | information will be output twice, once in each field. |
| 49 | |
| Martin Fick | db3be25 | 2010-09-15 13:59:54 -0600 | [diff] [blame] | 50 | \--all-approvals:: |
| 51 | Include information about all patch sets along with the |
| 52 | approval information for each patch set. If combined with |
| 53 | the \--current-patch-set flag then the current patch set |
| 54 | information will be output twice, once in each field. |
| 55 | |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 56 | limit:<n>:: |
| 57 | Maximum number of results to return. This is actually a |
| 58 | query operator, and not a command line option. If more |
| 59 | than one limit: operator is provided, the smallest limit |
| 60 | will be used to cut the result set. |
| 61 | |
| 62 | resume\_sortkey:<sortKey>:: |
| 63 | Resume results from this sort key. Callers should pass |
| 64 | the sortKey of the last change of the prior result set to |
| 65 | resume a prior query. This is actually a query operator, |
| 66 | and not a command line option. |
| 67 | |
| 68 | ACCESS |
| 69 | ------ |
| 70 | Any user who has configured an SSH key. |
| 71 | |
| 72 | SCRIPTING |
| 73 | --------- |
| 74 | This command is intended to be used in scripts. |
| 75 | |
| 76 | EXAMPLES |
| 77 | -------- |
| 78 | |
| 79 | Find the 2 most recent open changes in the tools/gerrit project: |
| 80 | ----- |
| 81 | $ ssh -p 29418 review.example.com gerrit query --format=JSON status:open project:tools/gerrit limit:2 |
| 82 | {"project":"tools/gerrit", ...} |
| 83 | {"project":"tools/gerrit", ..., sortKey:"000e6aee00003e26", ...} |
| 84 | {"type":"stats","rowCount":2,"runningTimeMilliseconds:15} |
| 85 | ----- |
| 86 | |
| 87 | Resume the same query and obtain the final results: |
| 88 | ----- |
| 89 | $ ssh -p 29418 review.example.com gerrit query --format=JSON status:open project:tools/gerrit limit:2 resume_sortkey:000e6aee00003e26 |
| 90 | {"project":"tools/gerrit", ...} |
| 91 | {"project":"tools/gerrit", ...} |
| 92 | {"type":"stats","rowCount":1,"runningTimeMilliseconds:15} |
| 93 | ----- |
| 94 | |
| 95 | |
| 96 | SCHEMA |
| 97 | ------ |
| 98 | The JSON messages consist of nested objects referencing the |
| 99 | link:json.html#change[change], |
| 100 | link:json.html#patchset[patchset], |
| 101 | link:json.html#[account] |
| 102 | involved, and other attributes as appropriate. |
| 103 | |
| 104 | Note that any field may be missing in the JSON messages, so consumers |
| 105 | of this JSON stream should deal with that appropriately. |
| 106 | |
| 107 | SEE ALSO |
| 108 | -------- |
| 109 | |
| 110 | * link:user-search.html[Query Operators] |
| 111 | * link:json.html[JSON Data Formats] |
| 112 | * link:access-control.html[Access Controls] |
| 113 | |
| 114 | GERRIT |
| 115 | ------ |
| 116 | Part of link:index.html[Gerrit Code Review] |