Skip to content

fix(repo view): consider current host when viewing a repo details

Jay McCure requested to merge jmc-1334 into main

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

From a non-default host: Screenshot_2023-06-27_at_12.15.19

From a default host: Screenshot_2023-06-27_at_12.23.16

From a non-git dir: Screenshot_2023-06-27_at_12.21.48

Screenshots (if appropriate):

Before: Screenshot_2023-06-19_at_17.23.26

After: Screenshot_2023-06-19_at_17.19.33

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
Edited by Jay McCure

Merge request reports