fix(repo view): consider current host when viewing a repo details
Description
glab project view
is not considering the host when the host of the current repo is different to the default host. This would affect users that have a self-managed instance but have gitlab.com as their default host (or vice versa).
In this scenario !glrepo.IsSame(repo, opts.Repo)
was evaluating to true every time since the host was not being considered, then a new client would be created pointing to the default instance.
These are the two tests that test this specific bug:
I added additional tests as there were some test gaps with this command.
Related Issues
Resolves #1334 (closed)
How has this been tested?
Configure glab to have two hosts - gitlab.com and GDK. Where gitlab.com is default.
Example yaml:
hosts:
gitlab.com:
token: ZZZ
api_protocol: https
api_host: gitlab.com
192.168.4.31:
token: ZZZ
api_host: 192.168.4.31:3000
git_protocol: ssh
api_protocol: http
# Default GitLab hostname to use
host: gitlab.com
Using GDK clone a repository From that repository's directory
-
glab repo view
or glab repo view --web
Repository should be viewed. Prior to this change it would attempt to open the repository on gitlab.com and fail
Additional tests
Screenshots (if appropriate):
Types of changes
-
Bug fix (non-breaking change which fixes an issue) -
New feature (non-breaking change which adds functionality) -
Breaking change (fix or feature that would cause existing functionality to change) -
Documentation -
Chore (Related to CI or Packaging to platforms) -
Test gap