Pygithub: create PullRequest between forked repo to original

Created on 16 May 2018  ·  2Comments  ·  Source: PyGithub/PyGithub

is there a method to create a pull request with the original repo as the base and a forked branch as the head?

I tried this line, but it threw a 'Validation Error'
repo.create_pull("Title", "Body", '{}:{}'.format(original_repo, master), '{}:{}'.format(forked_user, feature), True)

Most helpful comment

I think the way you wanted this, it's not possible when reading the API at https://developer.github.com/v3/pulls/#input for the base you can only pass a branch of the repository you are creating the PR on.

So you can only do:

original_repo.create_pull("Title", "Body", '{}'.format(master), '{}:{}'.format(forked_user, feature), True)

All 2 comments

I think the way you wanted this, it's not possible when reading the API at https://developer.github.com/v3/pulls/#input for the base you can only pass a branch of the repository you are creating the PR on.

So you can only do:

original_repo.create_pull("Title", "Body", '{}'.format(master), '{}:{}'.format(forked_user, feature), True)

Just clarifying, I tried this and ended up backwards.

From fork evandroforks to upstream tox-dev you should do:

upstream_user = github_api.get_user('tox-dev')
upstream_repo = upstream_user.get_repo('tox')

upstream_pullrequest = upstream_repo.create_pull("Title", "Body", 'master', 
          '{}:{}'.format('evandroforks', 'master'), True)

From upstream tox-dev to fork evandroforks you should do:

fork_user = github_api.get_user('evandroforks')
fork_repo = fork_user.get_repo('tox')

fork_pullrequest = fork_repo.create_pull("Title", "Body", 'master', 
          '{}:{}'.format('tox-dev', 'master'), False)
Was this page helpful?
0 / 5 - 0 ratings