Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for draft PRs #926

Closed
omgjlk opened this issue Feb 14, 2019 · 3 comments
Closed

Add support for draft PRs #926

omgjlk opened this issue Feb 14, 2019 · 3 comments
Assignees

Comments

@omgjlk
Copy link
Collaborator

omgjlk commented Feb 14, 2019

GitHub announced draft Pull Request status. Eventually they will add new fields to pull request listings and GETs to include the draft status, and allow setting a PR as draft when creating one. We'll want to support those things here!

I'll update this issue when the REST APIs are updated.

@omgjlk
Copy link
Collaborator Author

omgjlk commented Feb 16, 2019

There is now support for seeing draft status in responses to the REST API so I can get started on adding this.

omgjlk added a commit to omgjlk/github3.py that referenced this issue Feb 16, 2019
This adds response data support for the `draft` status of a pull
request. This was recently
[added](https://github.blog/2019-02-14-introducing-draft-pull-requests/)
to the platform and API. A PullRequest can be marked as a `draft` which
will prevent merging and delay triggering automatic pull request reviews
from `CODEOWNERS`.

Support for receiving the data is still in preview so new headers have
to be littered throughout the codebase.

Resolves: sigmavirus24#926
@staticdev
Copy link
Collaborator

@omgjlk anything missing on this PR? It is still draft.

@cjschaef
Copy link

Isn't the support to create new draft PR's still missing in main? I don't see a process to set draft in data when the request is made to the API.

def create_pull(
self, title, base, head, body=None, maintainer_can_modify=None
):
"""Create a pull request of ``head`` onto ``base`` branch in this repo.
:param str title:
(required)
:param str base:
(required), e.g., 'master'
:param str head:
(required), e.g., 'username:branch'
:param str body:
(optional), markdown formatted description
:param bool maintainer_can_modify:
(optional), Indicates whether a maintainer is allowed to modify the
pull request or not.
:returns:
the created pull request
:rtype:
:class:`~github3.pulls.ShortPullRequest`
"""
data = {"title": title, "body": body, "base": base, "head": head}
if maintainer_can_modify is not None:
data["maintainer_can_modify"] = maintainer_can_modify
return self._create_pull(data)
@decorators.requires_auth
def create_pull_from_issue(self, issue, base, head):
"""Create a pull request from issue #``issue``.
:param int issue:
(required), issue number
:param str base:
(required), e.g., 'master'
:param str head:
(required), e.g., 'username:branch'
:returns:
the created pull request
:rtype:
:class:`~github3.pulls.ShortPullRequest`
"""
if int(issue) > 0:
data = {"issue": issue, "base": base, "head": head}
return self._create_pull(data)
return None

Supported in Github API's via draft
https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#create-a-pull-request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants