Skip to content

Commit de8832a

Browse files
committed
Add qt-specific stage and unstage endpoints
1 parent f3d7074 commit de8832a

File tree

3 files changed

+41
-7
lines changed

3 files changed

+41
-7
lines changed

gerrit/changes/change.py

+34
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,40 @@ def submit(self, input_):
363363
result = self.gerrit.decode_response(response)
364364
return self.gerrit.changes.get(result.get("id"))
365365

366+
def stage(self):
367+
"""
368+
Stages a change in the Qt CI.
369+
370+
If the change cannot be staged because the QtStage rule doesn't allow staging the change,
371+
the response is 409 Conflict and the error message is contained in the response body.
372+
373+
.. code-block:: python
374+
change = gerrit.changes.get('myProject~stable~I10394472cbd17dd12454f229e4f6de00b143a444')
375+
result = change.stage()
376+
"""
377+
endpoint = "/changes/%s/revisions/current/gerrit-plugin-qt-workflow~stage" % self.id
378+
base_url = self.gerrit.get_endpoint_url(endpoint)
379+
response = self.gerrit.requester.post(
380+
base_url
381+
)
382+
result = self.gerrit.decode_response(response)
383+
return not result
384+
385+
def unstage(self):
386+
"""
387+
Unstages a change in the Qt CI.
388+
389+
If the change cannot be unstaged because the change is not currently staged,
390+
the response is 409 Conflict and the error message is contained in the response body.
391+
"""
392+
endpoint = "/changes/%s/revisions/current/gerrit-plugin-qt-workflow~unstage" % self.id
393+
base_url = self.gerrit.get_endpoint_url(endpoint)
394+
response = self.gerrit.requester.post(
395+
base_url
396+
)
397+
result = self.gerrit.decode_response(response)
398+
return not result
399+
366400
def delete(self):
367401
"""
368402
Deletes a change.

gerrit/projects/projects.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ def search(self, query):
4545

4646
def regex(self, query):
4747
"""
48-
Regex queries projects visible to the caller.
49-
The query string must be provided by the query parameter.
48+
Queries projects visible to the caller. The query string must be provided by the query parameter.
5049
The start and limit parameters can be used to skip/limit results.
5150
5251
query parameter
53-
* Boundary matchers '^' and '$' are implicit.
54-
* For example: the regex 'test.*' will match any projects that start with 'test' and regex
55-
'.*test' will match any project that end with 'test'.
56-
* The match is case sensitive.
52+
* name:'NAME' Matches projects that have exactly the name 'NAME'.
53+
* parent:'PARENT' Matches projects that have 'PARENT' as parent project.
54+
* inname:'NAME' Matches projects that a name part that starts with 'NAME' (case insensitive).
55+
* description:'DESCRIPTION' Matches projects whose description contains 'DESCRIPTION', using a full-text search.
56+
* state:'STATE' Matches project’s state. Can be either 'active' or 'read-only'.
5757
5858
:param query:
5959
:return:

gerrit/utils/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def parse_list(cls, data, **kwargs):
4141

4242
@classmethod
4343
def parse_dict(cls, data, **kwargs):
44-
"""Parse a dict of JSON objects into a result set of model instances."""
44+
"""Parse a list of JSON objects into a result set of model instances."""
4545
results = ResultSet()
4646
data = data or []
4747
for obj in data.keys():

0 commit comments

Comments
 (0)