Skip to content

Don't fetch every branch in contributor's remote when checking out a pull request #2030

@phil-blain

Description

@phil-blain

Thanks for this very nice extension!! It is really nice to review code in my code editor:)

I noticed that when I clicked the blue "Checkout" button in the pull request tab, the following happens:

  1. The extension adds a remote named after the GitHub username of the pull-request author (this remote is not deleted when I "Exit review mode")
  2. This new remote is fetched (this creates remote-tracking branches for all branches in the contributor's remote)
  3. The the source branch of the pull request is checked out (this branch is not deleted when I "Exit review mode")

I don't like 2), it pollutes the output of git branch -r.
I think the extension should only fetch the branch of the pull request, i.e.

git fetch $PR_AUTHOR_REMOTE_URL $PR_BRANCH:refs/heads/pr/$AUTHOR_GITHUB_USERNAME/$PR_NUMBER

In fact, adding a remote is not even necessary as Git can fetch a branch directly into FETCH_HEAD, and we can the checkout FETCH_HEADin detached HEAD.

I understand the current behaviour might be convenient for some, but maybe it could be configurable ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestRequest for new features or functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions