Skip to content

Fails to find issues and PRs correctly for active forks #867

Description

@allejo

Describe the bug

When I clone a repo that is an active fork (one that has no intentions of being merged back in), any gh command will call commands relative to the original repo.

For example, I am working on westonruter/syntax-highlighting-code-block, which is a fork and has completely diverged from the original project. Any gh command here will try hit the original repo (mkaz/code-syntax-block) this repo was forked from.

$ gh --version
gh version 0.7.0 (2020-04-22)
https://github.com/cli/cli/releases/tag/v0.7.0

Steps to reproduce the behavior

$ gh repo clone westonruter/syntax-highlighting-code-block
$ cd syntax-highlighting-code-block
$ gh pr checkout 93
graphql error: 'Could not resolve to a PullRequest with the number of 93.'

This happens because mkaz/code-syntax-block does not have a PR 93 but westonruter/syntax-highlighting-code-block does, so this command should be valid.

Expected vs actual behavior

I expect that if I am cloning a forked repository, any issues or pull requests I list/create via gh should take that forked repository as the target and not the original repository.

Activity

  1. mislav commented on May 7, 2020

    @mislav
    Contributor

    This was discussed at length in #350. The verdict at the time was that we will keep defaulting to the parent repo, since most people use their forks as means of sending patches only, but usually want to query issues/PRs in the canonical repo.

    The workaround for now is to use the -R flag to explicitly specify the repo you want to query: gh pr checkout 93 -R westonruter/syntax-highlighting-code-block.

    However, I do understand your use case. Now that we have a config mechanism, I wonder whether it would be worthwhile to add a per-repository config such as gh config --local base_remote origin so that people could explicitly opt-out of this behavior for their active forks.

    I'm going to re-classify this as a feature while we wait for more feedback.

  2. added
    enhancementa request to improve CLI
    and removed
    bugSomething isn't working
    on May 7, 2020
  3. SuperSandro2000 commented on May 28, 2020

    @SuperSandro2000
    Contributor

    I consider this a bug.

    I have the following repo cloned locally https://github.com/SuperSandro2000/supersandro2000.github.io/
    and want to checkout SuperSandro2000/supersandro.de#2 which fails. This does not really make sense cause the PR is against my fork and not the base repo.

  4. hierophect commented on Jun 17, 2020

    @hierophect

    I am also experiencing issues with this, as a contributor to a "friendly fork" project that merges from the parent repo occasionally but will never be merged in (https://github.com/adafruit/circuitpython). It's useful to know about the -R workaround, but since I need to use it for every command, a config option would definitely be nicer.

  5. elkowar commented on Sep 5, 2020

    @elkowar

    A per-repo config option for this would definitely be the way to go. At least mentioning the -R option when running gh pr list would be nice, something along the lines of showing PRs for parent repository. To see PRs on the fork <username>/<reponame>, specify '-R <username>/<reponame>'

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

    enhancementa request to improve CLI

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions