Skip to content

Infer what branch should be used as the compare branch (NDDB) #4766

Closed

Description

@iAmWillShepherd

In order to notify users that their current branch is behind, we need some way to determine which branch to use as the compare branch.

Criteria to determine compare branch (in priority order)

  1. If the current branch has a PR associated with it, use the target branch of the PR (this can be a branch that exists on eitherupstream ororigin)
  2. If the repository is a fork, use the default branch on upstream (this is usually master)
  3. If the repository is hosted on GitHub, use the default branch on origin (this is usually master)
  4. Otherwise fall through to the local master branch (conventionally, the default branch is master)

Notes on criteria
Criterion 1 and 3 are the most important ones to capture. Most times, the base branches of these two will be equivalent, origin/master.

Criteria 2 will likely be the most difficult as their are some edge cases we need to worry about. As I understand it, GitHub users create forks for two reasons:

  • To have a starting point for their own ideas
  • To propose changes to the repository they are forking from

We need to make sure we are careful to support both of these use-cases. We should be able to handle this by:

  1. Checking the default branch on the forked repository (likely origin/master)
  2. If no changes are found after performing step 1, check the default branch of the parent repository (likely upstream/master)

Activity

  1. added this to the milestone on May 23, 2018
  2. changed the title [-]Infer what branch should be used as the base branch (NDDB)[/-] [+]Infer what branch should be used as the compare branch (NDDB)[/+] on May 23, 2018
  3. locked as resolved and limited conversation to collaborators on Aug 18, 2018
  4. unlocked this conversation on Sep 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions