| Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 1 | = gerrit query |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 2 | |
| Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 3 | == NAME |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 4 | gerrit query - Query the change database |
| 5 | |
| Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 6 | == SYNOPSIS |
| Yuxuan 'fishy' Wang | d85b687 | 2013-11-15 11:47:46 -0800 | [diff] [blame] | 7 | -- |
| Shawn O. Pearce | 4776924 | 2011-06-14 16:40:48 -0700 | [diff] [blame] | 8 | 'ssh' -p <port> <host> 'gerrit query' |
| 9 | [--format {TEXT | JSON}] |
| 10 | [--current-patch-set] |
| 11 | [--patch-sets | --all-approvals] |
| Gustaf Lundh | 2ebc42d | 2011-11-02 17:21:05 +0100 | [diff] [blame] | 12 | [--files] |
| Mika Hamalainen | 0917a2b | 2011-07-22 14:21:28 +0300 | [diff] [blame] | 13 | [--comments] |
| Brad Larson | 0943d6e | 2011-10-27 19:36:27 -0500 | [diff] [blame] | 14 | [--commit-message] |
| Gregory Bean | e7232c4 | 2012-02-23 11:03:40 -0800 | [diff] [blame] | 15 | [--dependencies] |
| James E. Blair | 3fe3d3f | 2012-07-20 17:11:37 -0700 | [diff] [blame] | 16 | [--submit-records] |
| Mani Chandel | 72cb603 | 2013-10-17 17:12:03 +0530 | [diff] [blame] | 17 | [--all-reviewers] |
| David Ostrovsky | 6855018 | 2014-08-09 03:32:08 +0200 | [diff] [blame] | 18 | [--start <n> | -S <n>] |
| Shawn O. Pearce | 4776924 | 2011-06-14 16:40:48 -0700 | [diff] [blame] | 19 | [--] |
| 20 | <query> |
| 21 | [limit:<n>] |
| Yuxuan 'fishy' Wang | d85b687 | 2013-11-15 11:47:46 -0800 | [diff] [blame] | 22 | -- |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 23 | |
| Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 24 | == DESCRIPTION |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 25 | |
| 26 | Queries the change database and returns results describing changes |
| 27 | that match the input query. More recently updated changes appear |
| 28 | before older changes, which is the same order presented in the |
| David Pursehouse | 93a4ae6 | 2013-05-01 13:50:09 +0900 | [diff] [blame] | 29 | web interface. For each matching change, the result contains data |
| 30 | for the change's latest patch set, even if the query matched on an |
| 31 | older patch set (for example an older patch set's sha1 revision). |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 32 | |
| 33 | A query may be limited on the number of results it returns with the |
| 34 | 'limit:' operator. If no limit is supplied an internal default |
| 35 | limit is used to prevent explosion of the result set. To obtain |
| Alan Tokaev | 098272e | 2014-08-08 23:22:01 +0200 | [diff] [blame] | 36 | results beyond the limit, the '--start' flag can be used to resume |
| 37 | the query after skipping a certain number of results. |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 38 | |
| Shawn O. Pearce | 757df06 | 2012-11-30 11:20:37 -0800 | [diff] [blame] | 39 | Non-option arguments to this command are joined with spaces and |
| 40 | then parsed as a query. This simplifies calling conventions over |
| 41 | SSH by permitting operators to appear in different arguments. |
| 42 | |
| David Pursehouse | 93a4ae6 | 2013-05-01 13:50:09 +0900 | [diff] [blame] | 43 | Query operators may quote values using matched curly braces |
| Shawn O. Pearce | 757df06 | 2012-11-30 11:20:37 -0800 | [diff] [blame] | 44 | (e.g. `reviewerin:{Developer Group}`) to sidestep issues with 2 |
| 45 | levels of shell quoting (caller shell invoking SSH, and the SSH |
| 46 | command line parser in the server). |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 47 | |
| Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 48 | == OPTIONS |
| Shawn O. Pearce | 4776924 | 2011-06-14 16:40:48 -0700 | [diff] [blame] | 49 | --format:: |
| David Pursehouse | 93a4ae6 | 2013-05-01 13:50:09 +0900 | [diff] [blame] | 50 | Formatting method for the results. `TEXT` is the default, |
| 51 | presenting a human readable display. `JSON` returns |
| 52 | link:json.html#change[change attributes], one line |
| Shawn O. Pearce | 4776924 | 2011-06-14 16:40:48 -0700 | [diff] [blame] | 53 | per matching record, with embedded LFs escaped. |
| 54 | |
| 55 | --current-patch-set:: |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 56 | Include information about the current patch set in the results. |
| 57 | |
| Shawn O. Pearce | 4776924 | 2011-06-14 16:40:48 -0700 | [diff] [blame] | 58 | --patch-sets:: |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 59 | Include information about all patch sets. If combined with |
| Shawn O. Pearce | 4776924 | 2011-06-14 16:40:48 -0700 | [diff] [blame] | 60 | the --current-patch-set flag then the current patch set |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 61 | information will be output twice, once in each field. |
| 62 | |
| Shawn O. Pearce | 4776924 | 2011-06-14 16:40:48 -0700 | [diff] [blame] | 63 | --all-approvals:: |
| Martin Fick | db3be25 | 2010-09-15 13:59:54 -0600 | [diff] [blame] | 64 | Include information about all patch sets along with the |
| 65 | approval information for each patch set. If combined with |
| Shawn O. Pearce | 4776924 | 2011-06-14 16:40:48 -0700 | [diff] [blame] | 66 | the --current-patch-set flag then the current patch set |
| Martin Fick | db3be25 | 2010-09-15 13:59:54 -0600 | [diff] [blame] | 67 | information will be output twice, once in each field. |
| 68 | |
| Gustaf Lundh | 2ebc42d | 2011-11-02 17:21:05 +0100 | [diff] [blame] | 69 | --files:: |
| 70 | Support for listing files with patch sets and their |
| Bruce Zu | 1a9be5e | 2012-10-09 14:49:39 +0800 | [diff] [blame] | 71 | attributes (ADDED, MODIFIED, DELETED, RENAMED, COPIED) |
| 72 | and size information (number of insertions and deletions). |
| thomas.westling | 5a4d61b | 2011-12-29 16:34:45 +0100 | [diff] [blame] | 73 | Note that this option requires either the --current-patch-set |
| 74 | or the --patch-sets option in order to give any file information. |
| Gustaf Lundh | 2ebc42d | 2011-11-02 17:21:05 +0100 | [diff] [blame] | 75 | |
| Mika Hamalainen | 0917a2b | 2011-07-22 14:21:28 +0300 | [diff] [blame] | 76 | --comments:: |
| 77 | Include comments for all changes. If combined with the |
| Bruce Zu | 6b0fd76 | 2012-10-25 16:52:00 +0800 | [diff] [blame] | 78 | --patch-sets flag then all inline/file comments are included for |
| Mika Hamalainen | 0917a2b | 2011-07-22 14:21:28 +0300 | [diff] [blame] | 79 | each patch set. |
| 80 | |
| Brad Larson | 0943d6e | 2011-10-27 19:36:27 -0500 | [diff] [blame] | 81 | --commit-message:: |
| 82 | Include the full commit message in the change description. |
| 83 | |
| Gregory Bean | e7232c4 | 2012-02-23 11:03:40 -0800 | [diff] [blame] | 84 | --dependencies:: |
| 85 | Show information about patch sets which depend on, or are needed by, |
| 86 | each patch set. |
| 87 | |
| Mani Chandel | 72cb603 | 2013-10-17 17:12:03 +0530 | [diff] [blame] | 88 | --all-reviewers:: |
| 89 | Show the name and email of all reviewers which are added to a change |
| 90 | (irrespective of whether they have been voting on that change or not). |
| 91 | |
| James E. Blair | 3fe3d3f | 2012-07-20 17:11:37 -0700 | [diff] [blame] | 92 | --submit-records:: |
| 93 | Show submit record information about the change, which |
| 94 | includes whether the change meets the criteria for submission |
| 95 | (including information for each review label). |
| 96 | |
| David Ostrovsky | 6855018 | 2014-08-09 03:32:08 +0200 | [diff] [blame] | 97 | --start:: |
| 98 | -S:: |
| 99 | Number of changes to skip. |
| 100 | |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 101 | limit:<n>:: |
| 102 | Maximum number of results to return. This is actually a |
| 103 | query operator, and not a command line option. If more |
| 104 | than one limit: operator is provided, the smallest limit |
| 105 | will be used to cut the result set. |
| 106 | |
| Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 107 | == ACCESS |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 108 | Any user who has configured an SSH key. |
| 109 | |
| Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 110 | == SCRIPTING |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 111 | This command is intended to be used in scripts. |
| 112 | |
| Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 113 | == EXAMPLES |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 114 | |
| 115 | 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] | 116 | ==== |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 117 | $ ssh -p 29418 review.example.com gerrit query --format=JSON status:open project:tools/gerrit limit:2 |
| 118 | {"project":"tools/gerrit", ...} |
| Dave Borowitz | 4241459 | 2014-12-19 11:27:14 -0800 | [diff] [blame] | 119 | {"project":"tools/gerrit", ...} |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 120 | {"type":"stats","rowCount":2,"runningTimeMilliseconds:15} |
| Shawn O. Pearce | 4776924 | 2011-06-14 16:40:48 -0700 | [diff] [blame] | 121 | ==== |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 122 | |
| Alan Tokaev | 098272e | 2014-08-08 23:22:01 +0200 | [diff] [blame] | 123 | Skip number of changes: |
| Shawn O. Pearce | 4776924 | 2011-06-14 16:40:48 -0700 | [diff] [blame] | 124 | ==== |
| Alan Tokaev | 098272e | 2014-08-08 23:22:01 +0200 | [diff] [blame] | 125 | $ ssh -p 29418 review.example.com gerrit query --format=JSON --start 42 status:open project:tools/gerrit limit:2 |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 126 | {"project":"tools/gerrit", ...} |
| 127 | {"project":"tools/gerrit", ...} |
| 128 | {"type":"stats","rowCount":1,"runningTimeMilliseconds:15} |
| Shawn O. Pearce | 4776924 | 2011-06-14 16:40:48 -0700 | [diff] [blame] | 129 | ==== |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 130 | |
| 131 | |
| Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 132 | == SCHEMA |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 133 | The JSON messages consist of nested objects referencing the |
| 134 | link:json.html#change[change], |
| Edwin Kempin | a319d35 | 2012-09-06 10:28:11 +0200 | [diff] [blame] | 135 | link:json.html#patchSet[patchset], |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 136 | link:json.html#[account] |
| 137 | involved, and other attributes as appropriate. |
| 138 | |
| 139 | Note that any field may be missing in the JSON messages, so consumers |
| 140 | of this JSON stream should deal with that appropriately. |
| 141 | |
| Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 142 | == SEE ALSO |
| Shawn O. Pearce | 14760b7 | 2010-07-19 09:44:46 -0700 | [diff] [blame] | 143 | |
| 144 | * link:user-search.html[Query Operators] |
| 145 | * link:json.html[JSON Data Formats] |
| 146 | * link:access-control.html[Access Controls] |
| 147 | |
| 148 | GERRIT |
| 149 | ------ |
| 150 | Part of link:index.html[Gerrit Code Review] |
| Yuxuan 'fishy' Wang | 99cb68d | 2013-10-31 17:26:00 -0700 | [diff] [blame] | 151 | |
| 152 | SEARCHBOX |
| 153 | --------- |