Skip to content

Adding a tip about a pull request's base branch #431

Closed
@megbird

Description

@megbird

In these Halp tickets(content quoted 👇), users have asked us about what the expected behavior should be when a pull request's base branch is updated:

it seems like the .base.sha field is not always set to the actual base commit of the PR, but instead to the latest commit of the base branch at the time the PR got created.

Here's how to reproduce:

  1. Create a branch from master
  2. Add new commits to the branch
  3. Add new commits to master
  4. Create a PR for the branch
  5. Observe API results:

$ curl https://api.github.com/repos/neelance/apitest/pulls/1 | jq '.base.ref'
"master"
$ curl https://api.github.com/repos/neelance/apitest/pulls/1 | jq '.base.sha'
"c6e35b7668c32b21f08c8bad31e242f0862f6eb4"
$ curl https://api.github.com/repos/neelance/apitest/pulls/1/commits | jq '.[0].parents[0].sha'
"e726b8e3fb152fc4b172b234c69d884001fb87fa"

This behavior at least quite unexpected. I am currently also talking to the support of https://codecov.io/ because their system actually displays the wrong diff because of this.

also

I have a PR that has been opened for a few days now, and the base branch has been updated since then. However, while viewing diffs in the PR, it seems like the diffs are based on the base branch at the time of the creation of the PR.

So for example let's say my base branch is called "base" and the branch I want to merge is called "updates". Now on Monday I open a PR to merge updates into base. On Tuesday someone pushes new commits to base. The thing is, my PR opened on Monday doesn't take these in account, and the diff I'm viewing is the same I had on Monday.

Let's include a quick tip about it wherever best applicable, maybe in the Changing the base branch of a pull request article:

When you open a Pull Request, GitHub will set the base to the commit that branch references. If the branch is updated in the future, GitHub will not update the base branch's commit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions