Senthil Kumaran
Senthil Kumaran

Reputation: 56901

Github Pull Request API Differs from the web workflow

I am trying to use Github API to create pull request against an upstream repo

https://developer.github.com/v3/pulls/#create-a-pull-request

The API has the following parameters of interest.

head - 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.

base - 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.


This model assumes that while using API, I will be the upstream repo that I can merge changes from a fork:branch

This is opposite of how I work when I use their web-app. I can submit a Pull Request from my fork to the the upstream repo, which is denoted as (base-fork, base).

It seems to me that without having an access to upstream repo, using API, I cannot create pull-request against it. Can folks who have used github api confirm this?

Upvotes: 1

Views: 139

Answers (1)

Leon
Leon

Reputation: 32484

You don't need to have access to the upstream repository in order to submit a pull request against it, just like you don't need to have access to someone's email account when you send an email to them. Authenticate with your own credentials but post the request against the other user's repo.

This is opposite of how I work when I use their web-app. I can submit a Pull Request from my fork to the the upstream repo, which is denoted as (base-fork, base).

I can't see how the API method is different from the web-app flow. When you submit a Pull Request via the web-app, the Pull Request is recorded and shown in the base-fork repo (to which you may not have access). base-fork in the web-app corresponds to the repository against which you will post a create-pull-request API request.

According to the web-app documentation:

When thinking about branches, remember that the base branch is where changes should be applied, the head branch contains what you would like to be applied.

This exactly matches the meaning of the base and head parameters of the API request.

Upvotes: 1

Related Questions