Drop the port from remote-derived hosts so glab --hostname accepts them - #165
Merged
Conversation
parseRemoteUrl used URL.host for ssh:// and https:// remotes, which includes the port (ssh://git@gitlab.example.com:2222/group/project.git -> gitlab.example.com:2222). That value is passed to `glab api --hostname`, which rejects any host:port, so `codiff mr <n>` failed with "Unable to read repository" on GitLab instances whose remotes carry a custom port. Use URL.hostname instead. No behaviour change for remotes without a port, and the scp-style branch already had none. Adds regression tests for ssh/https remotes with ports. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Member
|
Yo! Thanks for the contribution. This doesn't work as it strips the port both from ssh and https protocols, but if you strip them from https, it will break the identifier. Can you limit port stripping to ssh and update the https test? |
An explicit port on https:// remotes is part of the instance identifier and must be kept; only the SSH transport port is dropped. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
Good catch, thanks — port stripping is now limited to |
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: drop port from remote host so
glab --hostnameaccepts itparseRemoteUrlusedURL.hostforssh:///https://remotes, which includes the port(
ssh://git@gitlab.example.com:2222/group/project.git→gitlab.example.com:2222). That value is passedto
glab api --hostname, which rejects anyhost:port→Error parsing --hostname: invalid hostnameand
codiff mr <n>fails with "Unable to read repository" on such GitLab instances.Use
URL.hostnameinstead. No behaviour change for remotes without a port (host === hostname);the scp-style branch already had no port.
Test added:
parseRemoteUrl('ssh://git@gitlab.example.com:2222/group/project.git')→host: 'gitlab.example.com'.Repro
Any repository whose
originremote is anssh://(orhttps://) URL with a port, e.g.Result (desktop window):
glabitself works fine in the same repo (glab mr view 1resolves the host from the remote).