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