blob: 090781b1bcaedb6f6160e719230af4db2214e029 [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 +090050 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. Pearce47769242011-06-14 16:40:48 -070053 per matching record, with embedded LFs escaped.
54
55--current-patch-set::
Shawn O. Pearce14760b72010-07-19 09:44:46 -070056 Include information about the current patch set in the results.
David Pursehousee2f4c2f2016-04-18 17:59:44 +090057 Note that the information will only be included when the current
58 patch set is visible to the caller.
Shawn O. Pearce14760b72010-07-19 09:44:46 -070059
Shawn O. Pearce47769242011-06-14 16:40:48 -070060--patch-sets::
David Pursehousee2f4c2f2016-04-18 17:59:44 +090061 Include information about all patch sets visible to the caller.
62 If combined with the --current-patch-set flag then the current patch
63 set information will be output twice, once in each field.
Shawn O. Pearce14760b72010-07-19 09:44:46 -070064
Shawn O. Pearce47769242011-06-14 16:40:48 -070065--all-approvals::
David Pursehousee2f4c2f2016-04-18 17:59:44 +090066 Include information about all patch sets visible to the caller along
67 with the approval information for each patch set. If combined with
Shawn O. Pearce47769242011-06-14 16:40:48 -070068 the --current-patch-set flag then the current patch set
Martin Fickdb3be252010-09-15 13:59:54 -060069 information will be output twice, once in each field.
70
Gustaf Lundh2ebc42d2011-11-02 17:21:05 +010071--files::
72 Support for listing files with patch sets and their
Bruce Zu1a9be5e2012-10-09 14:49:39 +080073 attributes (ADDED, MODIFIED, DELETED, RENAMED, COPIED)
74 and size information (number of insertions and deletions).
thomas.westling5a4d61b2011-12-29 16:34:45 +010075 Note that this option requires either the --current-patch-set
76 or the --patch-sets option in order to give any file information.
Gustaf Lundh2ebc42d2011-11-02 17:21:05 +010077
Mika Hamalainen0917a2b2011-07-22 14:21:28 +030078--comments::
79 Include comments for all changes. If combined with the
Bruce Zu6b0fd762012-10-25 16:52:00 +080080 --patch-sets flag then all inline/file comments are included for
David Pursehousee2f4c2f2016-04-18 17:59:44 +090081 each patch set that is visible to the caller.
Mika Hamalainen0917a2b2011-07-22 14:21:28 +030082
Brad Larson0943d6e2011-10-27 19:36:27 -050083--commit-message::
84 Include the full commit message in the change description.
85
Gregory Beane7232c42012-02-23 11:03:40 -080086--dependencies::
87 Show information about patch sets which depend on, or are needed by,
88 each patch set.
89
Mani Chandel72cb6032013-10-17 17:12:03 +053090--all-reviewers::
91 Show the name and email of all reviewers which are added to a change
92 (irrespective of whether they have been voting on that change or not).
93
James E. Blair3fe3d3f2012-07-20 17:11:37 -070094--submit-records::
95 Show submit record information about the change, which
96 includes whether the change meets the criteria for submission
97 (including information for each review label).
98
David Ostrovsky68550182014-08-09 03:32:08 +020099--start::
100-S::
101 Number of changes to skip.
102
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700103limit:<n>::
104 Maximum number of results to return. This is actually a
105 query operator, and not a command line option. If more
106 than one limit: operator is provided, the smallest limit
107 will be used to cut the result set.
108
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800109== ACCESS
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700110Any user who has configured an SSH key.
111
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800112== SCRIPTING
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700113This command is intended to be used in scripts.
114
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800115== EXAMPLES
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700116
117Find the 2 most recent open changes in the tools/gerrit project:
Shawn O. Pearce47769242011-06-14 16:40:48 -0700118====
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700119 $ ssh -p 29418 review.example.com gerrit query --format=JSON status:open project:tools/gerrit limit:2
120 {"project":"tools/gerrit", ...}
Dave Borowitz42414592014-12-19 11:27:14 -0800121 {"project":"tools/gerrit", ...}
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700122 {"type":"stats","rowCount":2,"runningTimeMilliseconds:15}
Shawn O. Pearce47769242011-06-14 16:40:48 -0700123====
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700124
Alan Tokaev098272e2014-08-08 23:22:01 +0200125Skip number of changes:
Shawn O. Pearce47769242011-06-14 16:40:48 -0700126====
Alan Tokaev098272e2014-08-08 23:22:01 +0200127 $ 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 -0700128 {"project":"tools/gerrit", ...}
129 {"project":"tools/gerrit", ...}
130 {"type":"stats","rowCount":1,"runningTimeMilliseconds:15}
Shawn O. Pearce47769242011-06-14 16:40:48 -0700131====
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700132
133
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800134== SCHEMA
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700135The JSON messages consist of nested objects referencing the
136link:json.html#change[change],
Edwin Kempina319d352012-09-06 10:28:11 +0200137link:json.html#patchSet[patchset],
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700138link:json.html#[account]
139involved, and other attributes as appropriate.
140
141Note that any field may be missing in the JSON messages, so consumers
142of this JSON stream should deal with that appropriately.
143
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800144== SEE ALSO
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700145
146* link:user-search.html[Query Operators]
147* link:json.html[JSON Data Formats]
148* link:access-control.html[Access Controls]
149
150GERRIT
151------
152Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700153
154SEARCHBOX
155---------