Skip to content

Commit

Permalink
Add qt-specific stage and unstage endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
DanSoQt committed Sep 3, 2021
1 parent f3d7074 commit de8832a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 7 deletions.
34 changes: 34 additions & 0 deletions gerrit/changes/change.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,40 @@ def submit(self, input_):
result = self.gerrit.decode_response(response)
return self.gerrit.changes.get(result.get("id"))

def stage(self):
"""
Stages a change in the Qt CI.
If the change cannot be staged because the QtStage rule doesn't allow staging the change,
the response is 409 Conflict and the error message is contained in the response body.
.. code-block:: python
change = gerrit.changes.get('myProject~stable~I10394472cbd17dd12454f229e4f6de00b143a444')
result = change.stage()
"""
endpoint = "/changes/%s/revisions/current/gerrit-plugin-qt-workflow~stage" % self.id
base_url = self.gerrit.get_endpoint_url(endpoint)
response = self.gerrit.requester.post(
base_url
)
result = self.gerrit.decode_response(response)
return not result

def unstage(self):
"""
Unstages a change in the Qt CI.
If the change cannot be unstaged because the change is not currently staged,
the response is 409 Conflict and the error message is contained in the response body.
"""
endpoint = "/changes/%s/revisions/current/gerrit-plugin-qt-workflow~unstage" % self.id
base_url = self.gerrit.get_endpoint_url(endpoint)
response = self.gerrit.requester.post(
base_url
)
result = self.gerrit.decode_response(response)
return not result

def delete(self):
"""
Deletes a change.
Expand Down
12 changes: 6 additions & 6 deletions gerrit/projects/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ def search(self, query):

def regex(self, query):
"""
Regex queries projects visible to the caller.
The query string must be provided by the query parameter.
Queries projects visible to the caller. The query string must be provided by the query parameter.
The start and limit parameters can be used to skip/limit results.
query parameter
* Boundary matchers '^' and '$' are implicit.
* For example: the regex 'test.*' will match any projects that start with 'test' and regex
'.*test' will match any project that end with 'test'.
* The match is case sensitive.
* name:'NAME' Matches projects that have exactly the name 'NAME'.
* parent:'PARENT' Matches projects that have 'PARENT' as parent project.
* inname:'NAME' Matches projects that a name part that starts with 'NAME' (case insensitive).
* description:'DESCRIPTION' Matches projects whose description contains 'DESCRIPTION', using a full-text search.
* state:'STATE' Matches project’s state. Can be either 'active' or 'read-only'.
:param query:
:return:
Expand Down
2 changes: 1 addition & 1 deletion gerrit/utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def parse_list(cls, data, **kwargs):

@classmethod
def parse_dict(cls, data, **kwargs):
"""Parse a dict of JSON objects into a result set of model instances."""
"""Parse a list of JSON objects into a result set of model instances."""
results = ResultSet()
data = data or []
for obj in data.keys():
Expand Down

0 comments on commit de8832a

Please sign in to comment.