pull-request-methods.rst
465 lines
| 17.4 KiB
| text/x-rst
|
RstLexer
r618 | .. _pull-request-methods-ref: | |||
pull_request methods | ||||
r989 | ==================== | |||
r618 | ||||
close_pull_request | ||||
------------------ | ||||
r2508 | .. py:function:: close_pull_request(apiuser, pullrequestid, repoid=<Optional:None>, userid=<Optional:<OptionalAttr:apiuser>>, message=<Optional:''>) | |||
r618 | ||||
Close the pull request specified by `pullrequestid`. | ||||
:param apiuser: This is filled automatically from the |authtoken|. | ||||
:type apiuser: AuthUser | ||||
:param repoid: Repository name or repository ID to which the pull | ||||
request belongs. | ||||
:type repoid: str or int | ||||
:param pullrequestid: ID of the pull request to be closed. | ||||
:type pullrequestid: int | ||||
:param userid: Close the pull request as this user. | ||||
:type userid: Optional(str or int) | ||||
r1841 | :param message: Optional message to close the Pull Request with. If not | |||
specified it will be generated automatically. | ||||
:type message: Optional(str) | ||||
r618 | ||||
Example output: | ||||
.. code-block:: bash | ||||
r1603 | "id": <id_given_in_input>, | |||
"result": { | ||||
r618 | "pull_request_id": "<int>", | |||
r1841 | "close_status": "<str:status_lbl>, | |||
r618 | "closed": "<bool>" | |||
}, | ||||
r1603 | "error": null | |||
r618 | ||||
comment_pull_request | ||||
-------------------- | ||||
r4355 | .. py:function:: comment_pull_request(apiuser, pullrequestid, repoid=<Optional:None>, message=<Optional:None>, commit_id=<Optional:None>, status=<Optional:None>, comment_type=<Optional:u'note'>, resolves_comment_id=<Optional:None>, extra_recipients=<Optional:[]>, userid=<Optional:<OptionalAttr:apiuser>>, send_email=<Optional:True>) | |||
r618 | ||||
Comment on the pull request specified with the `pullrequestid`, | ||||
in the |repo| specified by the `repoid`, and optionally change the | ||||
review status. | ||||
:param apiuser: This is filled automatically from the |authtoken|. | ||||
:type apiuser: AuthUser | ||||
r2508 | :param repoid: Optional repository name or repository ID. | |||
r618 | :type repoid: str or int | |||
:param pullrequestid: The pull request ID. | ||||
:type pullrequestid: int | ||||
r1395 | :param commit_id: Specify the commit_id for which to set a comment. If | |||
given commit_id is different than latest in the PR status | ||||
change won't be performed. | ||||
:type commit_id: str | ||||
r618 | :param message: The text content of the comment. | |||
:type message: str | ||||
:param status: (**Optional**) Set the approval status of the pull | ||||
r1395 | request. One of: 'not_reviewed', 'approved', 'rejected', | |||
'under_review' | ||||
r618 | :type status: str | |||
r1395 | :param comment_type: Comment type, one of: 'note', 'todo' | |||
:type comment_type: Optional(str), default: 'note' | ||||
r4174 | :param resolves_comment_id: id of comment which this one will resolve | |||
:type resolves_comment_id: Optional(int) | ||||
:param extra_recipients: list of user ids or usernames to add | ||||
notifications for this comment. Acts like a CC for notification | ||||
:type extra_recipients: Optional(list) | ||||
r618 | :param userid: Comment on the pull request as this user | |||
:type userid: Optional(str or int) | ||||
r4355 | :param send_email: Define if this comment should also send email notification | |||
:type send_email: Optional(bool) | ||||
r618 | ||||
Example output: | ||||
.. code-block:: bash | ||||
r1603 | id : <id_given_in_input> | |||
result : { | ||||
r618 | "pull_request_id": "<Integer>", | |||
r1395 | "comment_id": "<Integer>", | |||
"status": {"given": <given_status>, | ||||
"was_changed": <bool status_was_actually_changed> }, | ||||
r1603 | }, | |||
error : null | ||||
r618 | ||||
create_pull_request | ||||
------------------- | ||||
r4523 | .. py:function:: create_pull_request(apiuser, source_repo, target_repo, source_ref, target_ref, owner=<Optional:<OptionalAttr:apiuser>>, title=<Optional:''>, description=<Optional:''>, description_renderer=<Optional:''>, reviewers=<Optional:None>, observers=<Optional:None>) | |||
r618 | ||||
Creates a new pull request. | ||||
Accepts refs in the following formats: | ||||
* branch:<branch_name>:<sha> | ||||
* branch:<branch_name> | ||||
* bookmark:<bookmark_name>:<sha> (Mercurial only) | ||||
* bookmark:<bookmark_name> (Mercurial only) | ||||
:param apiuser: This is filled automatically from the |authtoken|. | ||||
:type apiuser: AuthUser | ||||
:param source_repo: Set the source repository name. | ||||
:type source_repo: str | ||||
:param target_repo: Set the target repository name. | ||||
:type target_repo: str | ||||
:param source_ref: Set the source ref name. | ||||
:type source_ref: str | ||||
:param target_ref: Set the target ref name. | ||||
:type target_ref: str | ||||
r3495 | :param owner: user_id or username | |||
:type owner: Optional(str) | ||||
r3000 | :param title: Optionally Set the pull request title, it's generated otherwise | |||
r618 | :type title: str | |||
:param description: Set the pull request description. | ||||
:type description: Optional(str) | ||||
r3000 | :type description_renderer: Optional(str) | |||
:param description_renderer: Set pull request renderer for the description. | ||||
It should be 'rst', 'markdown' or 'plain'. If not give default | ||||
system renderer will be used | ||||
r618 | :param reviewers: Set the new pull request reviewers list. | |||
r1841 | Reviewer defined by review rules will be added automatically to the | |||
defined list. | ||||
r618 | :type reviewers: Optional(list) | |||
r989 | Accepts username strings or objects of the format: | |||
r1603 | ||||
r1841 | [{'username': 'nick', 'reasons': ['original author'], 'mandatory': <bool>}] | |||
r4523 | :param observers: Set the new pull request observers list. | |||
Reviewer defined by review rules will be added automatically to the | ||||
defined list. This feature is only available in RhodeCode EE | ||||
:type observers: Optional(list) | ||||
Accepts username strings or objects of the format: | ||||
[{'username': 'nick', 'reasons': ['original author']}] | ||||
r618 | ||||
get_pull_request | ||||
---------------- | ||||
r4174 | .. py:function:: get_pull_request(apiuser, pullrequestid, repoid=<Optional:None>, merge_state=<Optional:False>) | |||
r618 | ||||
Get a pull request based on the given ID. | ||||
:param apiuser: This is filled automatically from the |authtoken|. | ||||
:type apiuser: AuthUser | ||||
r2508 | :param repoid: Optional, repository name or repository ID from where | |||
the pull request was opened. | ||||
r618 | :type repoid: str or int | |||
:param pullrequestid: ID of the requested pull request. | ||||
:type pullrequestid: int | ||||
r4174 | :param merge_state: Optional calculate merge state for each repository. | |||
This could result in longer time to fetch the data | ||||
:type merge_state: bool | ||||
r618 | ||||
Example output: | ||||
.. code-block:: bash | ||||
"id": <id_given_in_input>, | ||||
"result": | ||||
{ | ||||
"pull_request_id": "<pull_request_id>", | ||||
"url": "<url>", | ||||
"title": "<title>", | ||||
"description": "<description>", | ||||
"status" : "<status>", | ||||
"created_on": "<date_time_created>", | ||||
"updated_on": "<date_time_updated>", | ||||
r4355 | "versions": "<number_or_versions_of_pr>", | |||
r618 | "commit_ids": [ | |||
... | ||||
"<commit_id>", | ||||
"<commit_id>", | ||||
... | ||||
], | ||||
"review_status": "<review_status>", | ||||
"mergeable": { | ||||
"status": "<bool>", | ||||
"message": "<message>", | ||||
}, | ||||
"source": { | ||||
"clone_url": "<clone_url>", | ||||
"repository": "<repository_name>", | ||||
"reference": | ||||
{ | ||||
"name": "<name>", | ||||
"type": "<type>", | ||||
"commit_id": "<commit_id>", | ||||
} | ||||
}, | ||||
"target": { | ||||
"clone_url": "<clone_url>", | ||||
"repository": "<repository_name>", | ||||
"reference": | ||||
{ | ||||
"name": "<name>", | ||||
"type": "<type>", | ||||
"commit_id": "<commit_id>", | ||||
} | ||||
}, | ||||
r1169 | "merge": { | |||
r989 | "clone_url": "<clone_url>", | |||
r1169 | "reference": | |||
{ | ||||
"name": "<name>", | ||||
"type": "<type>", | ||||
"commit_id": "<commit_id>", | ||||
} | ||||
r989 | }, | |||
r618 | "author": <user_obj>, | |||
"reviewers": [ | ||||
... | ||||
{ | ||||
"user": "<user_obj>", | ||||
"review_status": "<review_status>", | ||||
} | ||||
... | ||||
] | ||||
}, | ||||
"error": null | ||||
r2508 | get_pull_request_comments | |||
------------------------- | ||||
.. py:function:: get_pull_request_comments(apiuser, pullrequestid, repoid=<Optional:None>) | ||||
Get all comments of pull request specified with the `pullrequestid` | ||||
:param apiuser: This is filled automatically from the |authtoken|. | ||||
:type apiuser: AuthUser | ||||
:param repoid: Optional repository name or repository ID. | ||||
:type repoid: str or int | ||||
:param pullrequestid: The pull request ID. | ||||
:type pullrequestid: int | ||||
Example output: | ||||
.. code-block:: bash | ||||
id : <id_given_in_input> | ||||
result : [ | ||||
{ | ||||
"comment_author": { | ||||
"active": true, | ||||
"full_name_or_username": "Tom Gore", | ||||
"username": "admin" | ||||
}, | ||||
"comment_created_on": "2017-01-02T18:43:45.533", | ||||
"comment_f_path": null, | ||||
"comment_id": 25, | ||||
"comment_lineno": null, | ||||
"comment_status": { | ||||
"status": "under_review", | ||||
"status_lbl": "Under Review" | ||||
}, | ||||
"comment_text": "Example text", | ||||
"comment_type": null, | ||||
r4455 | "comment_last_version: 0, | |||
r4355 | "pull_request_version": null, | |||
"comment_commit_id": None, | ||||
"comment_pull_request_id": <pull_request_id> | ||||
r2508 | } | |||
], | ||||
error : null | ||||
r618 | get_pull_requests | |||
----------------- | ||||
r4174 | .. py:function:: get_pull_requests(apiuser, repoid, status=<Optional:'new'>, merge_state=<Optional:False>) | |||
r618 | ||||
Get all pull requests from the repository specified in `repoid`. | ||||
:param apiuser: This is filled automatically from the |authtoken|. | ||||
:type apiuser: AuthUser | ||||
r2508 | :param repoid: Optional repository name or repository ID. | |||
r618 | :type repoid: str or int | |||
:param status: Only return pull requests with the specified status. | ||||
Valid options are. | ||||
* ``new`` (default) | ||||
* ``open`` | ||||
* ``closed`` | ||||
:type status: str | ||||
r3495 | :param merge_state: Optional calculate merge state for each repository. | |||
This could result in longer time to fetch the data | ||||
:type merge_state: bool | ||||
r618 | ||||
Example output: | ||||
.. code-block:: bash | ||||
"id": <id_given_in_input>, | ||||
"result": | ||||
[ | ||||
... | ||||
{ | ||||
"pull_request_id": "<pull_request_id>", | ||||
"url": "<url>", | ||||
"title" : "<title>", | ||||
"description": "<description>", | ||||
"status": "<status>", | ||||
"created_on": "<date_time_created>", | ||||
"updated_on": "<date_time_updated>", | ||||
"commit_ids": [ | ||||
... | ||||
"<commit_id>", | ||||
"<commit_id>", | ||||
... | ||||
], | ||||
"review_status": "<review_status>", | ||||
"mergeable": { | ||||
"status": "<bool>", | ||||
"message: "<message>", | ||||
}, | ||||
"source": { | ||||
"clone_url": "<clone_url>", | ||||
"reference": | ||||
{ | ||||
"name": "<name>", | ||||
"type": "<type>", | ||||
"commit_id": "<commit_id>", | ||||
} | ||||
}, | ||||
"target": { | ||||
"clone_url": "<clone_url>", | ||||
"reference": | ||||
{ | ||||
"name": "<name>", | ||||
"type": "<type>", | ||||
"commit_id": "<commit_id>", | ||||
} | ||||
}, | ||||
r1169 | "merge": { | |||
r989 | "clone_url": "<clone_url>", | |||
r1169 | "reference": | |||
{ | ||||
"name": "<name>", | ||||
"type": "<type>", | ||||
"commit_id": "<commit_id>", | ||||
} | ||||
r989 | }, | |||
r618 | "author": <user_obj>, | |||
"reviewers": [ | ||||
... | ||||
{ | ||||
"user": "<user_obj>", | ||||
"review_status": "<review_status>", | ||||
} | ||||
... | ||||
] | ||||
} | ||||
... | ||||
], | ||||
"error": null | ||||
merge_pull_request | ||||
------------------ | ||||
r2508 | .. py:function:: merge_pull_request(apiuser, pullrequestid, repoid=<Optional:None>, userid=<Optional:<OptionalAttr:apiuser>>) | |||
r618 | ||||
Merge the pull request specified by `pullrequestid` into its target | ||||
repository. | ||||
:param apiuser: This is filled automatically from the |authtoken|. | ||||
:type apiuser: AuthUser | ||||
r2508 | :param repoid: Optional, repository name or repository ID of the | |||
r618 | target repository to which the |pr| is to be merged. | |||
:type repoid: str or int | ||||
:param pullrequestid: ID of the pull request which shall be merged. | ||||
:type pullrequestid: int | ||||
:param userid: Merge the pull request as this user. | ||||
:type userid: Optional(str or int) | ||||
Example output: | ||||
.. code-block:: bash | ||||
r1603 | "id": <id_given_in_input>, | |||
"result": { | ||||
r3495 | "executed": "<bool>", | |||
"failure_reason": "<int>", | ||||
"merge_status_message": "<str>", | ||||
"merge_commit_id": "<merge_commit_id>", | ||||
"possible": "<bool>", | ||||
r1169 | "merge_ref": { | |||
"commit_id": "<commit_id>", | ||||
"type": "<type>", | ||||
"name": "<name>" | ||||
} | ||||
r618 | }, | |||
r1603 | "error": null | |||
r618 | ||||
update_pull_request | ||||
------------------- | ||||
r4523 | .. py:function:: update_pull_request(apiuser, pullrequestid, repoid=<Optional:None>, title=<Optional:''>, description=<Optional:''>, description_renderer=<Optional:''>, reviewers=<Optional:None>, observers=<Optional:None>, update_commits=<Optional:None>) | |||
r618 | ||||
Updates a pull request. | ||||
:param apiuser: This is filled automatically from the |authtoken|. | ||||
:type apiuser: AuthUser | ||||
r2508 | :param repoid: Optional repository name or repository ID. | |||
r618 | :type repoid: str or int | |||
:param pullrequestid: The pull request ID. | ||||
:type pullrequestid: int | ||||
:param title: Set the pull request title. | ||||
:type title: str | ||||
:param description: Update pull request description. | ||||
:type description: Optional(str) | ||||
r3000 | :type description_renderer: Optional(str) | |||
:param description_renderer: Update pull request renderer for the description. | ||||
It should be 'rst', 'markdown' or 'plain' | ||||
r618 | :param reviewers: Update pull request reviewers list with new value. | |||
:type reviewers: Optional(list) | ||||
r1841 | Accepts username strings or objects of the format: | |||
[{'username': 'nick', 'reasons': ['original author'], 'mandatory': <bool>}] | ||||
r4523 | :param observers: Update pull request observers list with new value. | |||
:type observers: Optional(list) | ||||
Accepts username strings or objects of the format: | ||||
r1841 | ||||
r4523 | [{'username': 'nick', 'reasons': ['should be aware about this PR']}] | |||
r618 | :param update_commits: Trigger update of commits for this pull request | |||
:type: update_commits: Optional(bool) | ||||
Example output: | ||||
.. code-block:: bash | ||||
r1603 | id : <id_given_in_input> | |||
result : { | ||||
r618 | "msg": "Updated pull request `63`", | |||
"pull_request": <pull_request_object>, | ||||
"updated_reviewers": { | ||||
"added": [ | ||||
"username" | ||||
], | ||||
"removed": [] | ||||
}, | ||||
r4523 | "updated_observers": { | |||
"added": [ | ||||
"username" | ||||
], | ||||
"removed": [] | ||||
}, | ||||
r618 | "updated_commits": { | |||
"added": [ | ||||
"<sha1_hash>" | ||||
], | ||||
"common": [ | ||||
"<sha1_hash>", | ||||
"<sha1_hash>", | ||||
], | ||||
"removed": [] | ||||
} | ||||
} | ||||
r1603 | error : null | |||
r618 | ||||