blob: 0ff59d4d3c811abdbc300eab7b742f07abbae1c5 [file] [log] [blame]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08001= gerrit query
Shawn O. Pearce14760b72010-07-19 09:44:46 -07002
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08003== NAME
Shawn O. Pearce14760b72010-07-19 09:44:46 -07004gerrit query - Query the change database
5
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08006== SYNOPSIS
Yuxuan 'fishy' Wangd85b6872013-11-15 11:47:46 -08007--
Shawn O. Pearce47769242011-06-14 16:40:48 -07008'ssh' -p <port> <host> 'gerrit query'
9 [--format {TEXT | JSON}]
10 [--current-patch-set]
11 [--patch-sets | --all-approvals]
Gustaf Lundh2ebc42d2011-11-02 17:21:05 +010012 [--files]
Mika Hamalainen0917a2b2011-07-22 14:21:28 +030013 [--comments]
Brad Larson0943d6e2011-10-27 19:36:27 -050014 [--commit-message]
Gregory Beane7232c42012-02-23 11:03:40 -080015 [--dependencies]
James E. Blair3fe3d3f2012-07-20 17:11:37 -070016 [--submit-records]
Mani Chandel72cb6032013-10-17 17:12:03 +053017 [--all-reviewers]
David Ostrovsky68550182014-08-09 03:32:08 +020018 [--start <n> | -S <n>]
Shawn O. Pearce47769242011-06-14 16:40:48 -070019 [--]
20 <query>
21 [limit:<n>]
Yuxuan 'fishy' Wangd85b6872013-11-15 11:47:46 -080022--
Shawn O. Pearce14760b72010-07-19 09:44:46 -070023
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080024== DESCRIPTION
Shawn O. Pearce14760b72010-07-19 09:44:46 -070025
26Queries the change database and returns results describing changes
27that match the input query. More recently updated changes appear
28before older changes, which is the same order presented in the
David Pursehouse93a4ae62013-05-01 13:50:09 +090029web interface. For each matching change, the result contains data
30for the change's latest patch set, even if the query matched on an
31older patch set (for example an older patch set's sha1 revision).
Shawn O. Pearce14760b72010-07-19 09:44:46 -070032
33A query may be limited on the number of results it returns with the
34'limit:' operator. If no limit is supplied an internal default
35limit is used to prevent explosion of the result set. To obtain
Alan Tokaev098272e2014-08-08 23:22:01 +020036results beyond the limit, the '--start' flag can be used to resume
37the query after skipping a certain number of results.
Shawn O. Pearce14760b72010-07-19 09:44:46 -070038
Shawn O. Pearce757df062012-11-30 11:20:37 -080039Non-option arguments to this command are joined with spaces and
40then parsed as a query. This simplifies calling conventions over
41SSH by permitting operators to appear in different arguments.
42
David Pursehouse93a4ae62013-05-01 13:50:09 +090043Query operators may quote values using matched curly braces
Shawn O. Pearce757df062012-11-30 11:20:37 -080044(e.g. `reviewerin:{Developer Group}`) to sidestep issues with 2
45levels of shell quoting (caller shell invoking SSH, and the SSH
46command line parser in the server).
Shawn O. Pearce14760b72010-07-19 09:44:46 -070047
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080048== OPTIONS
Shawn O. Pearce47769242011-06-14 16:40:48 -070049--format::
David Pursehouse93a4ae62013-05-01 13:50:09 +090050Formatting method for the results. `TEXT` is the default,
51presenting a human readable display. `JSON` returns
52link:json.html#change[change attributes], one line
Shawn O. Pearce47769242011-06-14 16:40:48 -070053per matching record, with embedded LFs escaped.
54
55--current-patch-set::
Shawn O. Pearce14760b72010-07-19 09:44:46 -070056Include information about the current patch set in the results.
57
Shawn O. Pearce47769242011-06-14 16:40:48 -070058--patch-sets::
Shawn O. Pearce14760b72010-07-19 09:44:46 -070059Include information about all patch sets. If combined with
Shawn O. Pearce47769242011-06-14 16:40:48 -070060the --current-patch-set flag then the current patch set
Shawn O. Pearce14760b72010-07-19 09:44:46 -070061information will be output twice, once in each field.
62
Shawn O. Pearce47769242011-06-14 16:40:48 -070063--all-approvals::
Martin Fickdb3be252010-09-15 13:59:54 -060064Include information about all patch sets along with the
65approval information for each patch set. If combined with
Shawn O. Pearce47769242011-06-14 16:40:48 -070066the --current-patch-set flag then the current patch set
Martin Fickdb3be252010-09-15 13:59:54 -060067information will be output twice, once in each field.
68
Gustaf Lundh2ebc42d2011-11-02 17:21:05 +010069--files::
70Support for listing files with patch sets and their
Bruce Zu1a9be5e2012-10-09 14:49:39 +080071attributes (ADDED, MODIFIED, DELETED, RENAMED, COPIED)
72and size information (number of insertions and deletions).
thomas.westling5a4d61b2011-12-29 16:34:45 +010073Note that this option requires either the --current-patch-set
74or the --patch-sets option in order to give any file information.
Gustaf Lundh2ebc42d2011-11-02 17:21:05 +010075
Mika Hamalainen0917a2b2011-07-22 14:21:28 +030076--comments::
77Include comments for all changes. If combined with the
Bruce Zu6b0fd762012-10-25 16:52:00 +080078--patch-sets flag then all inline/file comments are included for
Mika Hamalainen0917a2b2011-07-22 14:21:28 +030079each patch set.
80
Brad Larson0943d6e2011-10-27 19:36:27 -050081--commit-message::
82Include the full commit message in the change description.
83
Gregory Beane7232c42012-02-23 11:03:40 -080084--dependencies::
85Show information about patch sets which depend on, or are needed by,
86each patch set.
87
Mani Chandel72cb6032013-10-17 17:12:03 +053088--all-reviewers::
89Show 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. Blair3fe3d3f2012-07-20 17:11:37 -070092--submit-records::
93Show submit record information about the change, which
94includes whether the change meets the criteria for submission
95(including information for each review label).
96
David Ostrovsky68550182014-08-09 03:32:08 +020097--start::
98-S::
99Number of changes to skip.
100
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700101limit:<n>::
102Maximum number of results to return. This is actually a
103query operator, and not a command line option. If more
104than one limit: operator is provided, the smallest limit
105will be used to cut the result set.
106
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800107== ACCESS
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700108Any user who has configured an SSH key.
109
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800110== SCRIPTING
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700111This command is intended to be used in scripts.
112
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800113== EXAMPLES
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700114
115Find the 2 most recent open changes in the tools/gerrit project:
Shawn O. Pearce47769242011-06-14 16:40:48 -0700116====
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700117 $ ssh -p 29418 review.example.com gerrit query --format=JSON status:open project:tools/gerrit limit:2
118 {"project":"tools/gerrit", ...}
Dave Borowitz42414592014-12-19 11:27:14 -0800119 {"project":"tools/gerrit", ...}
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700120 {"type":"stats","rowCount":2,"runningTimeMilliseconds:15}
Shawn O. Pearce47769242011-06-14 16:40:48 -0700121====
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700122
Alan Tokaev098272e2014-08-08 23:22:01 +0200123Skip number of changes:
Shawn O. Pearce47769242011-06-14 16:40:48 -0700124====
Alan Tokaev098272e2014-08-08 23:22:01 +0200125 $ ssh -p 29418 review.example.com gerrit query --format=JSON --start 42 status:open project:tools/gerrit limit:2
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700126 {"project":"tools/gerrit", ...}
127 {"project":"tools/gerrit", ...}
128 {"type":"stats","rowCount":1,"runningTimeMilliseconds:15}
Shawn O. Pearce47769242011-06-14 16:40:48 -0700129====
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700130
131
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800132== SCHEMA
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700133The JSON messages consist of nested objects referencing the
134link:json.html#change[change],
Edwin Kempina319d352012-09-06 10:28:11 +0200135link:json.html#patchSet[patchset],
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700136link:json.html#[account]
137involved, and other attributes as appropriate.
138
139Note that any field may be missing in the JSON messages, so consumers
140of this JSON stream should deal with that appropriately.
141
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800142== SEE ALSO
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700143
144* link:user-search.html[Query Operators]
145* link:json.html[JSON Data Formats]
146* link:access-control.html[Access Controls]
147
148GERRIT
149------
150Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700151
152SEARCHBOX
153---------