Skip to main content

pull_request

Creates, updates, deletes, gets or lists a pull_request resource.

Overview

Namepull_request
TypeResource
Idgithub.pulls.pull_request

Fields

The following fields are returned by SELECT queries:

Pass the appropriate media type to fetch diff and patch formats.

NameDatatypeDescription
idinteger (int64)
node_idstring (example: MDExOlB1bGxSZXF1ZXN0MQ==)
_linksobject
active_lock_reasonstring (example: too heated)
additionsinteger
assigneeobjectA GitHub user. (title: Simple User)
assigneesarray
author_associationstringHow the author is associated with the repository. (COLLABORATOR, CONTRIBUTOR, FIRST_TIMER, FIRST_TIME_CONTRIBUTOR, MANNEQUIN, MEMBER, NONE, OWNER) (title: author_association, example: OWNER)
auto_mergeobjectThe status of auto merging a pull request. (title: Auto merge)
baseobject
bodystring (example: Please pull these awesome changes)
changed_filesinteger
closed_atstring (date-time) (example: 2011-01-26T19:01:12Z)
commentsinteger
comments_urlstring (uri) (example: https://api.github.com/repos/octocat/Hello-World/issues/1347/comments)
commitsinteger
commits_urlstring (uri) (example: https://api.github.com/repos/octocat/Hello-World/pulls/1347/commits)
created_atstring (date-time) (example: 2011-01-26T19:01:12Z)
deletionsinteger
diff_urlstring (uri) (example: https://github.com/octocat/Hello-World/pull/1347.diff)
draftbooleanIndicates whether or not the pull request is a draft.
headobject
html_urlstring (uri) (example: https://github.com/octocat/Hello-World/pull/1347)
issue_urlstring (uri) (example: https://api.github.com/repos/octocat/Hello-World/issues/1347)
labelsarray
lockedboolean
maintainer_can_modifybooleanIndicates whether maintainers can modify the pull request.
merge_commit_shastring (example: e5bd3914e2e596debea16f433f57875b5b90bcd6)
mergeableboolean
mergeable_statestring (example: clean)
mergedboolean
merged_atstring (date-time) (example: 2011-01-26T19:01:12Z)
merged_byobjectA GitHub user. (title: Simple User)
milestoneobjectA collection of related issues and pull requests. (title: Milestone)
numberintegerNumber uniquely identifying the pull request within its repository.
patch_urlstring (uri) (example: https://github.com/octocat/Hello-World/pull/1347.patch)
rebaseableboolean
requested_reviewersarray
requested_teamsarray
review_comment_urlstring (example: https://api.github.com/repos/octocat/Hello-World/pulls/comments{/number})
review_commentsinteger
review_comments_urlstring (uri) (example: https://api.github.com/repos/octocat/Hello-World/pulls/1347/comments)
statestringState of this Pull Request. Either open or closed. (open, closed) (example: open)
statuses_urlstring (uri) (example: https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e)
titlestringThe title of the pull request. (example: Amazing new feature)
updated_atstring (date-time) (example: 2011-01-26T19:01:12Z)
urlstring (uri) (example: https://api.github.com/repos/octocat/Hello-World/pulls/1347)
userobjectA GitHub user. (title: Simple User)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectowner, repo, pull_numberDraft 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.
createinsertowner, repo, head, baseDraft 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.
updateupdateowner, repo, pull_numberDraft 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_mergedexecowner, repo, pull_numberChecks 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.
mergeexecowner, repo, pull_numberMerges 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_branchexecowner, repo, pull_numberUpdates 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.

NameDatatypeDescription
ownerstringThe account owner of the repository. The name is not case sensitive.
pull_numberintegerThe number that identifies the pull request.
repostringThe name of the repository without the .git extension. The name is not case sensitive.

SELECT examples

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

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
;

UPDATE examples

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

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
;