summaryrefslogtreecommitdiffstats
path: root/Documentation/cmd-query.txt
blob: 90e5cdd01d447f381d02a4412790fedadf25726b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
= gerrit query

== NAME
gerrit query - Query the change database

== SYNOPSIS
[verse]
--
_ssh_ -p <port> <host> _gerrit query_
  [--format {TEXT | JSON}]
  [--current-patch-set]
  [--patch-sets | --all-approvals]
  [--files]
  [--comments]
  [--commit-message]
  [--dependencies]
  [--submit-records]
  [--all-reviewers]
  [--start <n> | -S <n>]
  [--]
  <query>
  [limit:<n>]
--

== DESCRIPTION

Queries the change database and returns results describing changes
that match the input query.  More recently updated changes appear
before older changes, which is the same order presented in the
web interface.  For each matching change, the result contains data
for the change's latest patch set, even if the query matched on an
older patch set (for example an older patch set's sha1 revision).

A query may be limited on the number of results it returns with the
'limit:' operator.  If no limit is supplied an internal default
limit is used to prevent explosion of the result set.  To obtain
results beyond the limit, the '--start' flag can be used to resume
the query after skipping a certain number of results.

Non-option arguments to this command are joined with spaces and
then parsed as a query. This simplifies calling conventions over
SSH by permitting operators to appear in different arguments.

Query operators may quote values using matched curly braces
(e.g. `reviewerin:{Developer Group}`) to sidestep issues with 2
levels of shell quoting (caller shell invoking SSH, and the SSH
command line parser in the server).

== OPTIONS
--format::
	Formatting method for the results. `TEXT` is the default,
	presenting a human readable display. `JSON` returns
	link:json.html#change[change attributes], one line
	per matching record, with embedded LFs escaped.

--current-patch-set::
	Include information about the current patch set in the results.
	Note that the information will only be included when the current
	patch set is visible to the caller.

--patch-sets::
	Include information about all patch sets visible to the caller.
        If combined with the --current-patch-set flag then the current patch
	set information will be output twice, once in each field.

--all-approvals::
	Include information about all patch sets visible to the caller along
	with the approval information for each patch set.  If combined with
	the --current-patch-set flag then the current patch set
	information will be output twice, once in each field.

--files::
	Support for listing files with patch sets and their
	attributes (ADDED, MODIFIED, DELETED, RENAMED, COPIED)
	and size information (number of insertions and deletions).
	Note that this option requires either the --current-patch-set
	or the --patch-sets option in order to give any file information.

--comments::
	Include comments for all changes. If combined with the
	--patch-sets flag then all inline/file comments are included for
	each patch set that is visible to the caller.

--commit-message::
	Include the full commit message in the change description.

--dependencies::
	Show information about patch sets which depend on, or are needed by,
	each patch set.

--all-reviewers::
	Show the name and email of all reviewers which are added to a change
	(irrespective of whether they have been voting on that change or not).

--submit-records::
	Show submit record information about the change, which
	includes whether the change meets the criteria for submission
	(including information for each review label).

--start::
-S::
	Number of changes to skip.

limit:<n>::
	Maximum number of results to return.  This is actually a
	query operator, and not a command line option.	If more
	than one limit: operator is provided, the smallest limit
	will be used to cut the result set.

== ACCESS
Any user who has SSH access to Gerrit.

== SCRIPTING
This command is intended to be used in scripts.

== EXAMPLES

Find the 2 most recent open changes in the tools/gerrit project:
----
  $ ssh -p 29418 review.example.com gerrit query --format=JSON status:open project:tools/gerrit limit:2
  {"project":"tools/gerrit", ...}
  {"project":"tools/gerrit", ...}
  {"type":"stats","rowCount":2,"runningTimeMilliseconds:15}
----

Skip number of changes:
----
  $ ssh -p 29418 review.example.com gerrit query --format=JSON --start 42 status:open project:tools/gerrit limit:2
  {"project":"tools/gerrit", ...}
  {"project":"tools/gerrit", ...}
  {"type":"stats","rowCount":1,"runningTimeMilliseconds:15}
----


== SCHEMA
The JSON messages consist of nested objects referencing the
link:json.html#change[change],
link:json.html#patchSet[patchset],
link:json.html#[account]
involved, and other attributes as appropriate.

Note that any field may be missing in the JSON messages, so consumers
of this JSON stream should deal with that appropriately.

== SEE ALSO

* link:user-search.html[Query Operators]
* link:json.html[JSON Data Formats]
* link:access-control.html[Access Controls]

GERRIT
------
Part of link:index.html[Gerrit Code Review]

SEARCHBOX
---------