blob: b20ac92cc2c8e45e34242e7248a3634e4da8644b [file] [log] [blame]
Shawn O. Pearce14760b72010-07-19 09:44:46 -07001gerrit query
2============
3
4NAME
5----
6gerrit query - Query the change database
7
8SYNOPSIS
9--------
10[verse]
Shawn O. Pearce47769242011-06-14 16:40:48 -070011'ssh' -p <port> <host> 'gerrit query'
12 [--format {TEXT | JSON}]
13 [--current-patch-set]
14 [--patch-sets | --all-approvals]
Mika Hamalainen0917a2b2011-07-22 14:21:28 +030015 [--comments]
Shawn O. Pearce47769242011-06-14 16:40:48 -070016 [--]
17 <query>
18 [limit:<n>]
19 [resume_sortkey:<sortKey>]
Shawn O. Pearce14760b72010-07-19 09:44:46 -070020
21DESCRIPTION
22-----------
23
24Queries the change database and returns results describing changes
25that match the input query. More recently updated changes appear
26before older changes, which is the same order presented in the
27web interface.
28
29A query may be limited on the number of results it returns with the
30'limit:' operator. If no limit is supplied an internal default
31limit is used to prevent explosion of the result set. To obtain
32results beyond the limit, the 'resume_sortkey:' operator can be used
33to resume the query at the change that follows the last change of
34the prior result set.
35
36Non-option arguments to this command are joined with spaces and then
37parsed as a query. This simplifies calling conventions over SSH
38by permitting operators to appear in different arguments without
39multiple levels of quoting required.
40
41OPTIONS
42-------
Shawn O. Pearce47769242011-06-14 16:40:48 -070043--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. Pearce14760b72010-07-19 09:44:46 -070049 Include information about the current patch set in the results.
50
Shawn O. Pearce47769242011-06-14 16:40:48 -070051--patch-sets::
Shawn O. Pearce14760b72010-07-19 09:44:46 -070052 Include information about all patch sets. If combined with
Shawn O. Pearce47769242011-06-14 16:40:48 -070053 the --current-patch-set flag then the current patch set
Shawn O. Pearce14760b72010-07-19 09:44:46 -070054 information will be output twice, once in each field.
55
Shawn O. Pearce47769242011-06-14 16:40:48 -070056--all-approvals::
Martin Fickdb3be252010-09-15 13:59:54 -060057 Include information about all patch sets along with the
58 approval information for each patch set. If combined with
Shawn O. Pearce47769242011-06-14 16:40:48 -070059 the --current-patch-set flag then the current patch set
Martin Fickdb3be252010-09-15 13:59:54 -060060 information will be output twice, once in each field.
61
Mika Hamalainen0917a2b2011-07-22 14:21:28 +030062--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. Pearce14760b72010-07-19 09:44:46 -070067limit:<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. Pearce47769242011-06-14 16:40:48 -070073resume_sortkey:<sortKey>::
Shawn O. Pearce14760b72010-07-19 09:44:46 -070074 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
79ACCESS
80------
81Any user who has configured an SSH key.
82
83SCRIPTING
84---------
85This command is intended to be used in scripts.
86
87EXAMPLES
88--------
89
90Find the 2 most recent open changes in the tools/gerrit project:
Shawn O. Pearce47769242011-06-14 16:40:48 -070091====
Shawn O. Pearce14760b72010-07-19 09:44:46 -070092 $ 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. Pearce47769242011-06-14 16:40:48 -070096====
Shawn O. Pearce14760b72010-07-19 09:44:46 -070097
98Resume the same query and obtain the final results:
Shawn O. Pearce47769242011-06-14 16:40:48 -070099====
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700100 $ 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. Pearce47769242011-06-14 16:40:48 -0700104====
Shawn O. Pearce14760b72010-07-19 09:44:46 -0700105
106
107SCHEMA
108------
109The JSON messages consist of nested objects referencing the
110link:json.html#change[change],
111link:json.html#patchset[patchset],
112link:json.html#[account]
113involved, and other attributes as appropriate.
114
115Note that any field may be missing in the JSON messages, so consumers
116of this JSON stream should deal with that appropriately.
117
118SEE 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
125GERRIT
126------
127Part of link:index.html[Gerrit Code Review]