gh-dash icon indicating copy to clipboard operation
gh-dash copied to clipboard

Select user

Open mg opened this issue 4 months ago • 3 comments

In my ~/.config/gh/hosts.yml I have two hosts defined, one for my personal github.com account and one for my corporate internal github account.

I have this .gh-dash.yml in my project folder

prSections:
  - title: "Open PRs in web/app"
    repos:
      - name: web/app
        hostname: git.lais.net

defaults:
  prsLimit: 20
  issuesLimit: 0

Because my personal github user is specificed in hots.yml before my corproate user, gh-dash automatically tries to use that user to query against git.lais.net and fails to return any results (it displays my personal username in the bottom bar). If I remove my personal github user from hosts, gh-dash now uses my corporate user and returns results.

It would be great if I could specify in .gh-dash.yml what user gh-dash should use in this project. Or is there any other method for me to start gh-dash and tell it to use a specific user without changing my hosts.yml file?

mg avatar Aug 12 '25 10:08 mg

dash also seems confused if there are multiple enterprise hosts in hosts.yml.

For example, given .config/gh/hosts/yml:

a.company.com:
    user: user-a
    git_protocol: ssh
b.company.com:
    user: user-b
    git_protocol: ssh

If I run dash in a repo for b.company.com, it just spins, and the logs show err="authentication token not found for host github.com" (even though the repo is not hosted on "github.com").

However, if I comment out the first entry, then it works.

It would be great if I could specify in .gh-dash.yml what user gh-dash should use in this project.

gh is able to detect which user to use based on the remotes in the repo, i.e. if I run gh pr list -A from any given repo, gh auto-selects the correct user/auth token. It seems like dash should be able to use the same logic.

rcorre avatar Sep 11 '25 20:09 rcorre

Odd ... it looks like this behavior is coming from the gh library: https://github.com/cli/go-gh/blob/trunk/pkg/auth/auth.go#L146-L157

Basically if there's more than one host, it defaults to github.com. I wonder how the CLI works.

rcorre avatar Sep 11 '25 20:09 rcorre

As a workaround, GH_HOST=your.enterprise.host gh dash seems to work

rcorre avatar Sep 11 '25 20:09 rcorre