feat: detect instanceUrl from git remotes and PATs
Part of #34 (closed)
find the intersection of git remotes hostnames and PATs hostnames, and if the intersection has exactly one hostname, use that as the instanceUrl otherwise, just do nothing.
Testing strategy
- The configured
instanceUrl
takes precedence- configure
"gitlab.instanceUrl"
in the workspace settings and make sure that GitLab Workflow always uses this instanceUrl
- configure
- We use the heuristic (no
instanceUrl
config)- We have 2 tokens configured
https://gitlab.com
-
https://dev.gitlab.org
(this can be any other instance)
- Have a project with only one remote
git remote -v dev git@dev.gitlab.org:gitlab/gitter/webapp.git (fetch) dev git@dev.gitlab.org:gitlab/gitter/webapp.git (push)
- Run
GitLab: Show issues assigned to me
command - The extension opens the
dev.gitlab.org
web
- Run
- Have a project with both remotes (heuristic matches 2 intersections)
git remote -v dev git@dev.gitlab.org:gitlab/gitter/webapp.git (fetch) dev git@dev.gitlab.org:gitlab/gitter/webapp.git (push) origin git@example.com:gitlab-org/gitter/webapp.git (fetch) origin git@example.com:gitlab-org/gitter/webapp.git (push)
- Run
GitLab: Show issues assigned to me
command - Extension tries to open the
gitlab.com
web (default)
- Run
- We have 2 tokens configured
Edited by Tomas Vik (OOO back on 2025-01-02)