pull_request
Creates, updates, deletes, gets or lists a pull_request resource.
Overview
| Name | pull_request |
| Type | Resource |
| Id | github.pulls.pull_request |
Fields
The following fields are returned by SELECT queries:
- get
Pass the appropriate media type to fetch diff and patch formats.
| Name | Datatype | Description |
|---|---|---|
id | integer (int64) | |
node_id | string | (example: MDExOlB1bGxSZXF1ZXN0MQ==) |
_links | object | |
active_lock_reason | string | (example: too heated) |
additions | integer | |
assignee | object | A GitHub user. (title: Simple User) |
assignees | array | |
author_association | string | How the author is associated with the repository. (COLLABORATOR, CONTRIBUTOR, FIRST_TIMER, FIRST_TIME_CONTRIBUTOR, MANNEQUIN, MEMBER, NONE, OWNER) (title: author_association, example: OWNER) |
auto_merge | object | The status of auto merging a pull request. (title: Auto merge) |
base | object | |
body | string | (example: Please pull these awesome changes) |
changed_files | integer | |
closed_at | string (date-time) | (example: 2011-01-26T19:01:12Z) |
comments | integer | |
comments_url | string (uri) | (example: https://api.github.com/repos/octocat/Hello-World/issues/1347/comments) |
commits | integer | |
commits_url | string (uri) | (example: https://api.github.com/repos/octocat/Hello-World/pulls/1347/commits) |
created_at | string (date-time) | (example: 2011-01-26T19:01:12Z) |
deletions | integer | |
diff_url | string (uri) | (example: https://github.com/octocat/Hello-World/pull/1347.diff) |
draft | boolean | Indicates whether or not the pull request is a draft. |
head | object | |
html_url | string (uri) | (example: https://github.com/octocat/Hello-World/pull/1347) |
issue_url | string (uri) | (example: https://api.github.com/repos/octocat/Hello-World/issues/1347) |
labels | array | |
locked | boolean | |
maintainer_can_modify | boolean | Indicates whether maintainers can modify the pull request. |
merge_commit_sha | string | (example: e5bd3914e2e596debea16f433f57875b5b90bcd6) |
mergeable | boolean | |
mergeable_state | string | (example: clean) |
merged | boolean | |
merged_at | string (date-time) | (example: 2011-01-26T19:01:12Z) |
merged_by | object | A GitHub user. (title: Simple User) |
milestone | object | A collection of related issues and pull requests. (title: Milestone) |
number | integer | Number uniquely identifying the pull request within its repository. |
patch_url | string (uri) | (example: https://github.com/octocat/Hello-World/pull/1347.patch) |
rebaseable | boolean | |
requested_reviewers | array | |
requested_teams | array | |
review_comment_url | string | (example: https://api.github.com/repos/octocat/Hello-World/pulls/comments{/number}) |
review_comments | integer | |
review_comments_url | string (uri) | (example: https://api.github.com/repos/octocat/Hello-World/pulls/1347/comments) |
state | string | State of this Pull Request. Either open or closed. (open, closed) (example: open) |
statuses_url | string (uri) | (example: https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e) |
title | string | The title of the pull request. (example: Amazing new feature) |
updated_at | string (date-time) | (example: 2011-01-26T19:01:12Z) |
url | string (uri) | (example: https://api.github.com/repos/octocat/Hello-World/pulls/1347) |
user | object | A GitHub user. (title: Simple User) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | owner, repo, pull_number | Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see GitHub's products in the GitHub Help documentation. Lists details of a pull request by providing its number. When you get, create, or edit a pull request, GitHub creates a merge commit to test whether the pull request can be automatically merged into the base branch. This test commit is not added to the base branch or the head branch. You can review the status of the test commit using the mergeable key. For more information, see "Checking mergeability of pull requests".The value of the mergeable attribute can be true, false, or null. If the value is null, then GitHub has started a background job to compute the mergeability. After giving the job time to complete, resubmit the request. When the job finishes, you will see a non-null value for the mergeable attribute in the response. If mergeable is true, then merge_commit_sha will be the SHA of the test merge commit.The value of the merge_commit_sha attribute changes depending on the state of the pull request. Before merging a pull request, the merge_commit_sha attribute holds the SHA of the test merge commit. After merging a pull request, the merge_commit_sha attribute changes depending on how you merged the pull request:* If merged as a merge commit, merge_commit_sha represents the SHA of the merge commit.* If merged via a squash, merge_commit_sha represents the SHA of the squashed commit on the base branch.* If rebased, merge_commit_sha represents the commit that the base branch was updated to.Pass the appropriate media type to fetch diff and patch formats. This endpoint supports the following custom media types. For more information, see "Media types." - application/vnd.github.raw+json: Returns the raw markdown body. Response will include body. This is the default if you do not pass any specific media type.- application/vnd.github.text+json: Returns a text only representation of the markdown body. Response will include body_text.- application/vnd.github.html+json: Returns HTML rendered from the body's markdown. Response will include body_html.- application/vnd.github.full+json: Returns raw, text, and HTML representations. Response will include body, body_text, and body_html.- application/vnd.github.diff: For more information, see "git-diff" in the Git documentation. If a diff is corrupt, contact us through the GitHub Support portal. Include the repository name and pull request ID in your message. | |
create | insert | owner, repo, head, base | Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see GitHub's products in the GitHub Help documentation. To open or update a pull request in a public repository, you must have write access to the head or the source branch. For organization-owned repositories, you must be a member of the organization that owns the repository to open or update a pull request. This endpoint triggers notifications. Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "Rate limits for the API" and "Best practices for using the REST API." This endpoint supports the following custom media types. For more information, see "Media types." - application/vnd.github.raw+json: Returns the raw markdown body. Response will include body. This is the default if you do not pass any specific media type.- application/vnd.github.text+json: Returns a text only representation of the markdown body. Response will include body_text.- application/vnd.github.html+json: Returns HTML rendered from the body's markdown. Response will include body_html.- application/vnd.github.full+json: Returns raw, text, and HTML representations. Response will include body, body_text, and body_html. | |
update | update | owner, repo, pull_number | Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see GitHub's products in the GitHub Help documentation. To open or update a pull request in a public repository, you must have write access to the head or the source branch. For organization-owned repositories, you must be a member of the organization that owns the repository to open or update a pull request. This endpoint supports the following custom media types. For more information, see "Media types." - application/vnd.github.raw+json: Returns the raw markdown body. Response will include body. This is the default if you do not pass any specific media type.- application/vnd.github.text+json: Returns a text only representation of the markdown body. Response will include body_text.- application/vnd.github.html+json: Returns HTML rendered from the body's markdown. Response will include body_html.- application/vnd.github.full+json: Returns raw, text, and HTML representations. Response will include body, body_text, and body_html. | |
check_if_merged | exec | owner, repo, pull_number | Checks if a pull request has been merged into the base branch. The HTTP status of the response indicates whether or not the pull request has been merged; the response body is empty. | |
merge | exec | owner, repo, pull_number | Merges a pull request into the base branch. This endpoint triggers notifications. Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "Rate limits for the API" and "Best practices for using the REST API." | |
update_branch | exec | owner, repo, pull_number | Updates the pull request branch with the latest upstream changes by merging HEAD from the base branch into the pull request branch. Note: If making a request on behalf of a GitHub App you must also have permissions to write the contents of the head repository. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
owner | string | The account owner of the repository. The name is not case sensitive. |
pull_number | integer | The number that identifies the pull request. |
repo | string | The name of the repository without the .git extension. The name is not case sensitive. |
SELECT examples
- get
Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see GitHub's products in the GitHub Help documentation.
Lists details of a pull request by providing its number.
When you get, create, or edit a pull request, GitHub creates a merge commit to test whether the pull request can be automatically merged into the base branch. This test commit is not added to the base branch or the head branch. You can review the status of the test commit using the mergeable key. For more information, see "Checking mergeability of pull requests".
The value of the mergeable attribute can be true, false, or null. If the value is null, then GitHub has started a background job to compute the mergeability. After giving the job time to complete, resubmit the request. When the job finishes, you will see a non-null value for the mergeable attribute in the response. If mergeable is true, then merge_commit_sha will be the SHA of the test merge commit.
The value of the merge_commit_sha attribute changes depending on the state of the pull request. Before merging a pull request, the merge_commit_sha attribute holds the SHA of the test merge commit. After merging a pull request, the merge_commit_sha attribute changes depending on how you merged the pull request:
* If merged as a merge commit, merge_commit_sha represents the SHA of the merge commit.
* If merged via a squash, merge_commit_sha represents the SHA of the squashed commit on the base branch.
* If rebased, merge_commit_sha represents the commit that the base branch was updated to.
Pass the appropriate media type to fetch diff and patch formats.
This endpoint supports the following custom media types. For more information, see "Media types."
- application/vnd.github.raw+json: Returns the raw markdown body. Response will include body. This is the default if you do not pass any specific media type.
- application/vnd.github.text+json: Returns a text only representation of the markdown body. Response will include body_text.
- application/vnd.github.html+json: Returns HTML rendered from the body's markdown. Response will include body_html.
- application/vnd.github.full+json: Returns raw, text, and HTML representations. Response will include body, body_text, and body_html.
- application/vnd.github.diff: For more information, see "git-diff" in the Git documentation. If a diff is corrupt, contact us through the GitHub Support portal. Include the repository name and pull request ID in your message.
SELECT
id,
node_id,
_links,
active_lock_reason,
additions,
assignee,
assignees,
author_association,
auto_merge,
base,
body,
changed_files,
closed_at,
comments,
comments_url,
commits,
commits_url,
created_at,
deletions,
diff_url,
draft,
head,
html_url,
issue_url,
labels,
locked,
maintainer_can_modify,
merge_commit_sha,
mergeable,
mergeable_state,
merged,
merged_at,
merged_by,
milestone,
number,
patch_url,
rebaseable,
requested_reviewers,
requested_teams,
review_comment_url,
review_comments,
review_comments_url,
state,
statuses_url,
title,
updated_at,
url,
user
FROM github.pulls.pull_request
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND pull_number = '{{ pull_number }}' -- required
;
INSERT examples
- create
- Manifest
Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see GitHub's products in the GitHub Help documentation.
To open or update a pull request in a public repository, you must have write access to the head or the source branch. For organization-owned repositories, you must be a member of the organization that owns the repository to open or update a pull request.
This endpoint triggers notifications. Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "Rate limits for the API" and "Best practices for using the REST API."
This endpoint supports the following custom media types. For more information, see "Media types."
- application/vnd.github.raw+json: Returns the raw markdown body. Response will include body. This is the default if you do not pass any specific media type.
- application/vnd.github.text+json: Returns a text only representation of the markdown body. Response will include body_text.
- application/vnd.github.html+json: Returns HTML rendered from the body's markdown. Response will include body_html.
- application/vnd.github.full+json: Returns raw, text, and HTML representations. Response will include body, body_text, and body_html.
INSERT INTO github.pulls.pull_request (
title,
head,
head_repo,
base,
body,
maintainer_can_modify,
draft,
issue,
owner,
repo
)
SELECT
'{{ title }}',
'{{ head }}' /* required */,
'{{ head_repo }}',
'{{ base }}' /* required */,
'{{ body }}',
{{ maintainer_can_modify }},
{{ draft }},
{{ issue }},
'{{ owner }}',
'{{ repo }}'
RETURNING
id,
node_id,
_links,
active_lock_reason,
additions,
assignee,
assignees,
author_association,
auto_merge,
base,
body,
changed_files,
closed_at,
comments,
comments_url,
commits,
commits_url,
created_at,
deletions,
diff_url,
draft,
head,
html_url,
issue_url,
labels,
locked,
maintainer_can_modify,
merge_commit_sha,
mergeable,
mergeable_state,
merged,
merged_at,
merged_by,
milestone,
number,
patch_url,
rebaseable,
requested_reviewers,
requested_teams,
review_comment_url,
review_comments,
review_comments_url,
state,
statuses_url,
title,
updated_at,
url,
user
;
# Description fields are for documentation purposes
- name: pull_request
props:
- name: owner
value: "{{ owner }}"
description: Required parameter for the pull_request resource.
- name: repo
value: "{{ repo }}"
description: Required parameter for the pull_request resource.
- name: title
value: "{{ title }}"
description: |
The title of the new pull request. Required unless `issue` is specified.
- name: head
value: "{{ head }}"
description: |
The name of the branch where your changes are implemented. For cross-repository pull requests in the same network, namespace `head` with a user like this: `username:branch`.
- name: head_repo
value: "{{ head_repo }}"
description: |
The name of the repository where the changes in the pull request were made. This field is required for cross-repository pull requests if both repositories are owned by the same organization.
- name: base
value: "{{ base }}"
description: |
The name of the branch you want the changes pulled into. This should be an existing branch on the current repository. You cannot submit a pull request to one repository that requests a merge to a base of another repository.
- name: body
value: "{{ body }}"
description: |
The contents of the pull request.
- name: maintainer_can_modify
value: {{ maintainer_can_modify }}
description: |
Indicates whether [maintainers can modify](https://docs.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/) the pull request.
- name: draft
value: {{ draft }}
description: |
Indicates whether the pull request is a draft. See "[Draft Pull Requests](https://docs.github.com/articles/about-pull-requests#draft-pull-requests)" in the GitHub Help documentation to learn more.
- name: issue
value: {{ issue }}
description: |
An issue in the repository to convert to a pull request. The issue title, body, and comments will become the title, body, and comments on the new pull request. Required unless `title` is specified.
UPDATE examples
- update
Draft pull requests are available in public repositories with GitHub Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see GitHub's products in the GitHub Help documentation.
To open or update a pull request in a public repository, you must have write access to the head or the source branch. For organization-owned repositories, you must be a member of the organization that owns the repository to open or update a pull request.
This endpoint supports the following custom media types. For more information, see "Media types."
- application/vnd.github.raw+json: Returns the raw markdown body. Response will include body. This is the default if you do not pass any specific media type.
- application/vnd.github.text+json: Returns a text only representation of the markdown body. Response will include body_text.
- application/vnd.github.html+json: Returns HTML rendered from the body's markdown. Response will include body_html.
- application/vnd.github.full+json: Returns raw, text, and HTML representations. Response will include body, body_text, and body_html.
UPDATE github.pulls.pull_request
SET
title = '{{ title }}',
body = '{{ body }}',
state = '{{ state }}',
base = '{{ base }}',
maintainer_can_modify = {{ maintainer_can_modify }}
WHERE
owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND pull_number = '{{ pull_number }}' --required
RETURNING
id,
node_id,
_links,
active_lock_reason,
additions,
assignee,
assignees,
author_association,
auto_merge,
base,
body,
changed_files,
closed_at,
comments,
comments_url,
commits,
commits_url,
created_at,
deletions,
diff_url,
draft,
head,
html_url,
issue_url,
labels,
locked,
maintainer_can_modify,
merge_commit_sha,
mergeable,
mergeable_state,
merged,
merged_at,
merged_by,
milestone,
number,
patch_url,
rebaseable,
requested_reviewers,
requested_teams,
review_comment_url,
review_comments,
review_comments_url,
state,
statuses_url,
title,
updated_at,
url,
user;
Lifecycle Methods
- check_if_merged
- merge
- update_branch
Checks if a pull request has been merged into the base branch. The HTTP status of the response indicates whether or not the pull request has been merged; the response body is empty.
EXEC github.pulls.pull_request.check_if_merged
@owner='{{ owner }}' --required,
@repo='{{ repo }}' --required,
@pull_number='{{ pull_number }}' --required
;
Merges a pull request into the base branch.
This endpoint triggers notifications. Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see "Rate limits for the API" and "Best practices for using the REST API."
EXEC github.pulls.pull_request.merge
@owner='{{ owner }}' --required,
@repo='{{ repo }}' --required,
@pull_number='{{ pull_number }}' --required
@@json=
'{
"commit_title": "{{ commit_title }}",
"commit_message": "{{ commit_message }}",
"sha": "{{ sha }}",
"merge_method": "{{ merge_method }}"
}'
;
Updates the pull request branch with the latest upstream changes by merging HEAD from the base branch into the pull request branch.
Note: If making a request on behalf of a GitHub App you must also have permissions to write the contents of the head repository.
EXEC github.pulls.pull_request.update_branch
@owner='{{ owner }}' --required,
@repo='{{ repo }}' --required,
@pull_number='{{ pull_number }}' --required
@@json=
'{
"expected_head_sha": "{{ expected_head_sha }}"
}'
;