Skip to content

gh "base repository" not worktree specific #1837

Description

@davezarzycki

gh version 1.0.0 (2020-09-16)

Setup: a "bare" git repository with multiple remotes and multiple git worktrees. For example: both https://github.com/llvm/llvm-project and https://github.com/apple/llvm-project

Problem: Unlike similar git workflows, gh asks the user to pick a "base repository" which is tied to the bare repository, not branches nor worktrees.

Workaround: create a wrapper around gh that tries to set GH_REPO as needed. In short, the script will extract the GitHub URL from git and pass it to gh: git config remote.$(git config branch.$(git branch --show-current).remote).url

Finally, and unless I missed something, the "base repository" feature seems undocumented.

Activity

  1. added
    priority-3Affects a small number of users or is largely cosmetic
    on Sep 30, 2020
  2. mislav commented on Oct 16, 2020

    @mislav
    Contributor

    @davezarzycki Hi, thanks for writing in! You are right that right now, a "base" repo will be saved per git repository (not per-branch or per-worktree). You are also right that the base repository feature is currently undocumented.

    To help me understand your use case: when you switch between branches/worktrees, how would you prefer the "base" repo being selected for querying issues or choosing a base repository for newly created PRs?

  3. davezarzycki commented on Oct 16, 2020

    @davezarzycki
    Author

    I'd just formalize the workaround listed above: if the local branch has an upstream/tracking branch, then extract the "remote" of the upstream branch and use that as the GitHub "base".

    This approach implicitly works with git worktrees.

  4. vilmibm commented on Dec 15, 2020

    @vilmibm
    Contributor

    I'm not sure that this is a bug; it seems like more of a desired enhancement around gh's awareness of a user using multiple worktrees. Re-labeling as such.

  5. added
    coreThis issue is not accepting PRs from outside contributors
    enhancementa request to improve CLI
    and removed
    bugSomething isn't working
    more-info-neededMore info needed from user/contributor
    priority-3Affects a small number of users or is largely cosmetic
    on Dec 15, 2020
  6. davezarzycki commented on Dec 16, 2020

    @davezarzycki
    Author

    The title of this isn't great. Sorry. This open issue is also about working with multiple remotes too, not just multiple worktrees.

  7. mislav commented on Dec 16, 2020

    @mislav
    Contributor

    @davezarzycki Thanks for getting back to us! More specifics would be really useful for us to understand how we can improve gh in this manner. For example: in a local repository with remotes X and Y, when in a worktree so-and-so, I expect gh <command> to query information from GitHub repo Z.

  8. davezarzycki commented on Dec 16, 2020

    @davezarzycki
    Author

    Hi @mislav — On Oct 16th, you asked what I thought gh should do, and I replied "just formalize the workaround" (i.e. implement the workaround I described earlier in gh). If I might repeat myself using different words:

    If the GH_REPO environmental variable is not explicitly set, then derive the value as much as possible at runtime. If the active / checked out branch has an upstream/tracking branch, then extract the repository from that and use it. Otherwise, if an upstream/tracking branch does not exist and only one remote is defined, then use that.

    This logic doesn't require any special handling to make worktrees work as a bonus. :-)

    Am I missing something about what more information you want?

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

    coreThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLI

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions