Skip to content

gh pr create when branch is on a fork  #2001

Description

@maramSalamouny

Describe the feature or problem you’d like to solve

Doing gh pr create on a branch that's pushed to a fork doesn't detect the branch properly. Running the same command before pushing allows you to choose the remote and then correctly detects it when creating the PR.

Proposed solution

How will it benefit CLI and its users? A lot of people push branches to their forks not to the main repo!

Additional context

Without pushing first

`

gh pr create
Warning: 4 uncommitted changes
? Where should we push the 'tests' branch? maram/testRepo
Creating pull request for tests into master in ORG/testRepo
? Title tests
? Body
? What's next? Continue in browser
Enumerating objects: 15, done.
Counting objects: 100% (15/15), done.
Delta compression using up to 12 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (8/8), 730 bytes | 730.00 KiB/s, done.
Total 8 (delta 5), reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5), completed with 5 local objects.
To https:///maram/testRepo.git 2f524a467..9e1b2d88a HEAD -> tests
Branch 'tests' set up to track remote branch 'tests' from 'origin'.
Opening /ORG/testRepo/compare/master...maram:tests in your browser.`. <<< correctly detects my fork!!

With pushing first

`

gh pr create
Creating pull request for tests into master in ORG/testRepo
? Title tests
? Body
? What's next? Continue in browser
Opening /ORG/testRepo/compare/master...tests in your browser.`

Activity

  1. added
    enhancement
    on Sep 28, 2020
  2. bodograumann commented on Sep 28, 2020

    @bodograumann

    This just caused me a lot of pain. I meticulously created a pull request and when I wanted to submit it, I just got:

    pull request create failed: GraphQL error: Head sha can't be blank, Base sha can't be blank, No commits between master and ts-enum-type, Head ref must be a branch

    Now my PR text is gone 😢

    gh version 1.0.0 (2020-09-17)

  3. added
    bug
    priority-1
    and removed
    enhancement
    on Sep 28, 2020
  4. wandergeek commented on Nov 26, 2020

    @wandergeek

    @mislav There seems to be a regression in the latest release (1.3.0 (2020-11-24)). PR creations using forks seem to be chopping off the fork name from the url.

    For example, the tool visits https://github.com/org/repo/compare/master...branch instead of https://github.com/org/repo/compare/master...wandergeek:branch

    Even running in interactive mode, I get the same result:

    $ gh pr create
    
    Creating pull request for wandergeek:branch into master in org/repo
    
    ? Title my cool title
    ? Body <Received>
    ? What's next? Continue in browser
    Opening github.com/elastic/cloud/compare/master...branch in your browser.
    
  5. mislav commented on Dec 1, 2020

    @mislav
    Contributor

    @wandergeek You're right, there is a regression. Thank you for letting us know! We have a fix under way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority-1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions