Add support for supplying a port name for a GitHub host
- Dominant language
- Go
- Stars
- 46.3k
- Forks
- 9k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 89
Description
Ran into a small papercut with `GH_HOST` env var
When adding a port to the host, for example `github.localhost:xxx`, the CLI does not correctly identify it as a local instance as
in https://github.com/cli/cli/blob/ba27e5bfb88bab29021ae0eace03348e41f0b24f/internal/ghinstance/host.go#L60 and https://github.com/cli/cli/blob/ba27e5bfb88bab29021ae0eace03348e41f0b24f/internal/ghinstance/host.go#L73 we look for equality which doesn’t match if the user includes the port. The result is an incorrect path for the api and protocol (https instead of http).
This can be fixed by either
- remapping the server port to 80, which may not always be possible
- not including the port in the `GH_HOST` env var
It’s not a blocker but it was surprising behavior which took me a few minutes to understand and unblock myself.
As a follow up thought, I wonder if it's worth handling the IP for localhost `127.0.0.1` as well.
### Describe the bug
A clear and concise description of what the bug is. Include version by typing `gh --version`.
### Steps to reproduce the behavior
As an example:
```
GH_HOST="github.localhost:56530" gh api graphql -F query='
query viewer {
viewer{
id
}
}
'
```
will make a `Post "https://github.localhost:56530/api/graphql"` request.
### Expected vs actual behavior
With a GH_HOST for localhost the API path should be match https://github.com/cli/cli/blob/ba27e5bfb88bab29021ae0eace03348e41f0b24f/internal/ghinstance/host.go#L61
Contributor guide
Assessment
This issue has not been assessed yet.