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