vscode-gitlens icon indicating copy to clipboard operation
vscode-gitlens copied to clipboard

Configured remotes not showing up in quickpick menu when opening commit on remote

Open IvanRadakovic opened this issue 5 years ago • 22 comments

I set the output level to debug, but it doesn't output anything.

  • GitLens Version: 2021.3.1104
  • Git Version: 2.28.0
  • VSCode Version: 1.54.3
  • OS Version: macOS 11.2.3

Steps to Reproduce:

  1. set gitlens.integrations.enabled to true
  2. Based on https://github.com/eamodio/vscode-gitlens#remote-provider-integration-settings- add this to settings "gitlens.remotes": [{ "domain": "code.company.com", "type": "Custom", "name": "company", "protocol": "https", "urls": { "repository": "https://code.company.com/packages/${repo}", "branches": "https://code.company.com/packages/${repo}/repo-info", "branch": "https://code.company.com/packages/${repo}/trees/heads/${branch}", "commit": "https://code.company.com/packages/${repo}/commits/${id}", "file": "https://code.company.com/packages/${repo}?path=${file}${line}", "fileInBranch": "https://code.company.com/packages/${repo}/blobs/${branch}/--/${file}${line}", "fileInCommit": "https://code.company.com/packages/${repo}/blobs/${id}/--/${file}${line}", "fileLine": "#L${line}", "fileRange": "#L${start}-L${end}" } }],
  3. Save
  4. Restart VS Code
  5. Go to COMMITS tab in source controll.
  6. Click 'Open Commit on Remote' next to a commit

Expected: opens commit on the configured remote. Actual: 'No auto-detected or configured remote providers found' shows up in quickpick menu as if nothing was ever configured

IvanRadakovic avatar Mar 30 '21 20:03 IvanRadakovic

Yup, experiencing this.

sarthak-k avatar Apr 02 '21 13:04 sarthak-k

Can either of you post what the output of git remote -vv returns? Because the domain of the custom remote definition has to match the domain of your Git remote.

eamodio avatar Apr 06 '21 04:04 eamodio

Certainly, it's different. But the purpose with Custom remote should enable us to add any domain, I believe we should treat this as a bug.

sarthak-k avatar Apr 06 '21 13:04 sarthak-k

So the domain and git remote -vv are different, but I was under the impression that this would still allow us to open a webpage in the browser using this template: https://code.company.com/packages/${repo}/commits/${id} with the repo and id fillied in from that corresponding commit.

IvanRadakovic avatar Apr 06 '21 22:04 IvanRadakovic

The gitlens.remotes property allows you to configure custom remote "matchers", so GitLens can use those configured custom remotes in addition to its built-in remote support for GitHub, Bitbucket, etc, to match against your repository remotes. If a match is found, then the urls configuration is used to open resources. So the domain property or the newly added regex property must be specified to perform that match.

eamodio avatar Apr 06 '21 22:04 eamodio

Ah I see. That makes sense. I ran into another issue. So git remote -vv shows this

backup  ssh://git.company.com:2222/pkg/RepoName/backup/username (fetch)
backup  ssh://git.company.com:2222/pkg/RepoName/backup/username (push)
origin  ssh://git.company.com:2222/pkg/RepoName (fetch)
origin  ssh://git.company.com:2222/pkg/RepoName (push)
share   ssh://git.company.com:2222/pkg/RepoName/share/username (fetch)

I have changed the domain to be git.company.com. However now ${repo} in the URL resolves to pkg/RepoName(https://code.company.com/packages/pkg/RepoName) instead of just RepoName (https://code.company.com/packages/RepoName).

IvanRadakovic avatar Apr 07 '21 18:04 IvanRadakovic

So for that you'll need to use the regex property instead of domain and the first capture group is the domain part and the 2nd capture group is the repo

eamodio avatar Apr 07 '21 23:04 eamodio

This issue needs more information and has not had recent activity. Please provide the missing information or it will be closed in 7 days. Thanks!

github-actions[bot] avatar Apr 15 '21 05:04 github-actions[bot]

So for that you'll need to use the regex property instead of domain and the first capture group is the domain part and the 2nd capture group is the repo

@eamodio I am facing the same issue here. Could you please provide an example? I couldn't find it in the README.md document. Thanks!

zainfathoni avatar Apr 20 '21 02:04 zainfathoni

For this domain origin ssh://git.company.com:2222/pkg/RepoName (fetch)

I tried

"regex": "ssh:\\/\\/(git.company.com):2222\\/pkg\\/(\\w+)"
"regex": "(ssh:\\/\\/git.company.com:2222)\\/pkg\\/(\\w+)"
"regex": "ssh:\/\/(git.company.com):2222\/pkg\/(\\w+)"
"regex": "(ssh:\/\/git.company.com:2222)\/pkg\/(\\w+)"

and none of them work. Could you please add documentation in the README.md on how use the regex property with some examples.

IvanRadakovic avatar Apr 21 '21 18:04 IvanRadakovic

This issue needs more information and has not had recent activity. Please provide the missing information or it will be closed in 7 days. Thanks!

github-actions[bot] avatar Apr 29 '21 05:04 github-actions[bot]

I have the original problem (No auto-detected or configured remote providers found). I have several equivalent remotes defined (for configuration reasons), and my employer has a custom protocol (sso), could either of those cause the problem?

$ git remote -vv
origin  sso://our-domain/repo-name (fetch)
origin  sso://our-domain/repo-name (push)
origin-3.2.0-hotfixes   sso://our-domain/repo-name (fetch)
origin-3.2.0-hotfixes   sso://our-domain/repo-name (push)
origin-v3.0.0   sso://our-domain/repo-name (fetch)
origin-v3.0.0   sso://our-domain/repo-name (push)
...

settings.json:

    "gitlens.integrations.enabled": true,
    "gitlens.remotes": [{
        "domain": "our-domain",
        "type": "Custom",
        "name": "Company Name",
        "protocol": "sso",
        "urls": {
            "repository": "...",
            "branches": "...",
            "branch": "...",
            "commit": "...",
            "file": "...",
            "fileInBranch": "...",
            "fileInCommit": "...",
            "fileLine": "...",
            "fileRange": "..."
        }
    }]

objectiveryan avatar May 05 '21 16:05 objectiveryan

This issue needs more information and has not had recent activity. Please provide the missing information or it will be closed in 7 days. Thanks!

github-actions[bot] avatar May 13 '21 05:05 github-actions[bot]

Is there some more information I can provide? I don't want this issue to be closed – it still affects me.

objectiveryan avatar May 17 '21 14:05 objectiveryan

This also affects me, It used to work before but doesn't anymore, what information do you need?

priteshacharya avatar May 17 '21 19:05 priteshacharya

FYI I tried removing my other remotes, so there's only one:

$ git remote -vv
origin  sso://our-domain/repo-name (fetch)
origin  sso://our-domain/repo-name (push)
$

I've tried setting gitlens.integrations.enabled and gitlens.remotes in my user settings and/or workspace settings (first one, then both, then only the other). I quit and restart VSCode. I still get "No auto-detected or configured remote providers found" :-(

Also, I typically ssh into a remote server to work (through VSCode's Remote - SSH extension), but I tried working out of a local folder and had the same problem.

objectiveryan avatar Jun 03 '21 17:06 objectiveryan

Bump. Having the same issue here trying to use Bitbucket with GitLens. :-(

lodotek avatar Jun 11 '21 16:06 lodotek

Sorry for the delay and confusion around this issue. I think I've gotten to the bottom of it, and I added 2 new examples in the README that use the regex property.

Can you please verify this fix in tomorrow's GitLens insiders edition?

You can install the GitLens insiders edition from here. Be sure to disable/uninstall the stable version of GitLens first.

eamodio avatar Jun 15 '21 07:06 eamodio

Hey thank you so much for the fix!

It works for me. However, I got an Invalid escape character in string error when using what you had in the README example:

"ssh:\/\/(my\.company\.com):1234\/git\/(.+)"

This is because \. is not a valid escape character in JSON. This caused me to dig deeper into what is actually required. To make it work, you could replace \. with just .

"ssh:\/\/(my.company.com):1234\/git\/(.+)"

which works, but it could match other incorrect strings as well because of the wild card. A better fix would be to properly escape the \ by replacing \. with \\.

"ssh:\/\/(my\\.company\\.com):1234\/git\/(.+)"

I also found out that in JSON, you can, but are not required to escape /. \/ is just as valid as /. Allowing \/ helps when embedding JSON in a <script> tag, which doesn't allow </ inside strings. So this means that the example in the README could be simplified to only escape the . with two \ and leaving everything else alone.

"ssh://(my\\.company\\.com):1234/git/(.+)"

IvanRadakovic avatar Jun 23 '21 23:06 IvanRadakovic

Thanks, I've fixed the example.

eamodio avatar Jun 28 '21 04:06 eamodio