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

Make possible to move a PR from Draft to Ready #2989

Open
dudu opened this issue Jun 10, 2024 · 13 comments · May be fixed by #3104
Open

Make possible to move a PR from Draft to Ready #2989

dudu opened this issue Jun 10, 2024 · 13 comments · May be fixed by #3104

Comments

@dudu
Copy link

dudu commented Jun 10, 2024

Today is possible to create a PR as a draft with the Repo.create_pull method, but I didn't find a way to make a draft PR ready, since the PullRequest.edit doesn't support the draft attribute as specified on Github Documentation.
Am I correct? Can I submit a PR for this feature?

@dudu dudu changed the title Make possible to move a PR from Draf to Ready Make possible to move a PR from Draft to Ready Jun 10, 2024
@guymatz
Copy link

guymatz commented Aug 15, 2024

It looks like this is not possible. :-( The GH doc for updating a PR says "State of this Pull Request. Either open or closed"

@swetharao12
Copy link

gh api is available to make draft to ready but there are other challenges of assigning reviewers/team reviewers

@swetharao12
Copy link

swetharao12 commented Aug 21, 2024

challenge to remove as team reviewers

image

@swetharao12
Copy link

swetharao12 commented Aug 21, 2024

  • draft mode to ready mode
  • gh api subprocess call for calling to draft mode to ready mode
  • gh api subprocess call to add team-reviewers
  • remove team reviewers (attached the challenge, gh api is not capable of doing this, we have to look at other libraries like ocktokit etc

@guymatz
Copy link

guymatz commented Aug 21, 2024

  • draft mode to ready mode

HOW? What about Ready -> Draft? Thanks!

@swetharao12
Copy link

swetharao12 commented Aug 21, 2024

  • draft mode to ready mode

HOW? What about Ready -> Draft? Thanks!

use the api call to convert to draft -> true

@guymatz
Copy link

guymatz commented Aug 21, 2024

This doesn't work: pr.update({'draft':'true'}), nor does pr.edit(state="draft")
Can you please give an example? Thanks!!

@swetharao12
Copy link

you have to use pygit subprocess ` result = subprocess.run(
[path_to_gh, "pr", "view", str(pr_number), "--repo", f"{owner}/{repo_name}"],
capture_output=True, text=True,
env={"GH_TOKEN": token}
)

    if "Draft: false" in result.stdout:
        logger.info("PR #%s is already ready for review", pr_number)
        return

    subprocess.run(
        [path_to_gh, "pr", "ready", str(pr_number), "--repo", f"{owner}/{repo_name}"],
        env={"GH_TOKEN": token},
        check=True
    )`

@guymatz
Copy link

guymatz commented Aug 28, 2024

Thanks, but that's not using PyGithub . . .

@swetharao12
Copy link

Thanks, but that's not using PyGithub . . .

yes, that is the limitation, you will have to go to Octokit lib

@jakirkham
Copy link

On this GitHub doc page, they mention that the GitHub CLI has a gh pr ready. Looking at the function source it appears they are using the newer GraphQL API to mark a PR as ready for review

This SO answer comes to a similar conclusion and references issue ( google/go-github#1120 ) with more details

@EnricoMi
Copy link
Collaborator

EnricoMi commented Sep 29, 2024

Looking at the REST API, it does not look like you can modify the draft attribute there: https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#update-a-pull-request

Looking at the GraphQL API, marking a pull request as "ready for review" seems to be the desired action: https://docs.github.com/en/graphql/reference/input-objects#markpullrequestreadyforreviewinput

There is prior art of calling out to the GraphQL API in PyGithub:
https://github.com/PyGithub/PyGithub/blob/85087354078e426125dbbf88041bbaa6f35d8199/github/PullRequest.py#L787.L824

So this feature should be easy to add. Contribution welcome!

@jakirkham
Copy link

Indeed one of my collaborators pointed out this discussion thread, which had a workable approach: https://github.com/orgs/community/discussions/70061

@didot didot linked a pull request Jan 6, 2025 that will close this issue
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.

5 participants