bugthesystem / vscode-open-in-github

Extension for Visual Studio Code which can be used to jump to a source code line in Github, Bitbucket, GitLab and Visualstudio.com
MIT License
197 stars 73 forks source link

Extension use wrong remote url with Gerrit hosted projects #107

Open ssbarnea opened 5 years ago

ssbarnea commented 5 years ago

I observed that the extension attempted to open gerrit url instead of github for openstack repositories even if git config --get remote.origin.url does clearly report a GitHub url:

$ git config --get remote.origin.url                                                                                                                                                                                                                                                                                                                             [11:34:04]
https://github.com/openstack-infra/tripleo-ci.git

I guess that the extension use another way to determine the provider.

I suppose that this was caused by the fact that current branch was using remote = gerrit and it decided to open it using gerrit, and failed ugly trying to open an invalid url like https://review.openstack.org:29418/openstack-infra/tripleo-ci/blob/708f9c87f4c4529fb2963c3dbd9a4ea2bae9deb2/playbooks/tripleo-ci/templates/oooq_common_functions.sh.j2#L113

From .git/config

[remote "origin"]
    url = https://github.com/openstack-infra/tripleo-ci.git
    fetch = +refs/heads/*:refs/remotes/origin/*

[remote "gerrit"]
    url = ssh://ssbarnea@review.openstack.org:29418/openstack-infra/tripleo-ci.git
    fetch = +refs/heads/*:refs/remotes/gerrit/*

Gerrit remote is configured automatically by git-review, and clearly is not something that "open-in-github" should ever attempt to use.

Most likely all local branches would point to . or gerrit remotes as that's how we push the code. Still the origin branch is safe to use for establishing the GitHub repository location.

Can we sort this out?

sunjiyun26 commented 5 years ago

the same problem