Skip to content

gh pr status shows 'no pull request associated' on a branch pulled via gh pr checkout from a fork #5914

Closed

Description

@Frederick888

Describe the bug

gh pr status seems to have trouble identifying PR if current branch is from a fork.

Steps to reproduce the behavior

I was trying to review and merge Frederick888/external-editor-revived#37 locally.

$ gh pr checkout 37
From https://github.com/Frederick888/external-editor-revived
 * [new ref]         refs/pull/37/head -> rlcintra/master
Switched to branch 'rlcintra/master'
$ git remote -v
origin  https://github.com/Frederick888/external-editor-revived.git (fetch)
origin  [email protected]:Frederick888/external-editor-revived.git (push)
$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
[remote "origin"]
        url = https://github.com/Frederick888/external-editor-revived.git
        fetch = +refs/heads/*:refs/remotes/origin/*
        gh-resolved = base
        pushurl = [email protected]:Frederick888/external-editor-revived.git
[branch "master"]
        remote = origin
        merge = refs/heads/master
[branch "rlcintra/master"]
        remote = [email protected]:rlcintra/external-editor-revived.git
        pushRemote = [email protected]:rlcintra/external-editor-revived.git
        merge = refs/heads/master

^ All these looked normal, but

$ gh pr status

Relevant pull requests in Frederick888/external-editor-revived

Current branch
  There is no pull request associated with [rlcintra:rlcintra/master]

Created by you
  You have no open pull requests

Requesting a code review from you
  You have no pull requests to review
$ gh pr status --json number,baseRefName,headRefName,headRepositoryOwner
{
  "createdBy": [],
  "needsReview": []
}

Expected vs actual behavior

gh pr status returns info about Frederick888/external-editor-revived#37

Perhaps if a user adds a remote for the fork then fetches everything manually, it's ok for gh-cli to not be able to identify such branches; but if it's pulled via gh pr checkout, I'd expect gh pr status to report correct info.

Logs

Activity

  1. mislav commented on Jul 11, 2022

    @mislav
    Contributor

    Thank you for reporting!

    From this line, I'm guessing that gh misinterpreted the name of the remote branch (it's supposed to be master, not rlcintra/master which is the local branch name):

    There is no pull request associated with [rlcintra:rlcintra/master]
    

    I cannot reproduce on my end. Are you running the latest version of gh?

  2. added
    more-info-neededMore info needed from user/contributor
    and removed on Jul 11, 2022
  3. Frederick888 commented on Jul 11, 2022

    @Frederick888
    ContributorAuthor

    Sorry totally forgot to post that.

    Yup I'm using

    gh version 2.13.0 (2022-06-22)
    https://github.com/cli/cli/releases/tag/v2.13.0
    
  4. mislav commented on Jul 11, 2022

    @mislav
    Contributor

    Thank you; I've managed to track this down and propose a PR with a fix.

  5. added
    priority-3Affects a small number of users or is largely cosmetic
    and removed
    more-info-neededMore info needed from user/contributor
    on Jul 11, 2022
  6. Frederick888 commented on Jul 11, 2022

    @Frederick888
    ContributorAuthor

    Wow that was quick. Thanks a ton!

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

    bugSomething isn't workingpriority-3Affects a small number of users or is largely cosmetic

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions