Skip to content

Filter common git hosting providers from SSH config hosts#51528

Merged
nathansobo merged 3 commits intozed-industries:mainfrom
sarmadgulzar:fix/filter-git-providers-from-ssh-host-list
Mar 18, 2026
Merged

Filter common git hosting providers from SSH config hosts#51528
nathansobo merged 3 commits intozed-industries:mainfrom
sarmadgulzar:fix/filter-git-providers-from-ssh-host-list

Conversation

@sarmadgulzar
Copy link
Copy Markdown
Contributor

@sarmadgulzar sarmadgulzar commented Mar 13, 2026

Fixes #50218

  • For every Host block: collect its host patterns (handling continuations and filtering !/*/\), remember any Hostname.
  • When the block ends: if Hostname is a git provider → discard everything.
  • Else if Hostname exists → keep all host aliases.
  • Else → keep only the host aliases that are not git providers.

Added more extensive test coverage as well to cover the above!

Release Notes:

  • Fixed SSH host picker showing git provider domains (e.g. github.com, gitlab.com) from SSH config.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 13, 2026
@sarmadgulzar sarmadgulzar changed the title fix/filter git providers from ssh host list Filter common git hosting providers from SSH config hosts Mar 13, 2026
@zelenenka zelenenka added the guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions label Mar 16, 2026
@sarmadgulzar
Copy link
Copy Markdown
Contributor Author

sarmadgulzar commented Mar 18, 2026

@injust this PR needs another review.

@esthertrapadoux @JosephTLyons

@nathansobo
Copy link
Copy Markdown
Contributor

Thanks for this, @sarmadgulzar! I pushed a revision with some structural changes:

  • Two-pass design: parse_host_blocks handles all the SSH config parsing (keywords, backslash continuations, block boundaries) and returns a Vec<HostBlock>. The public function then just filters and collects.

  • HostBlock::non_git_provider_hosts: Moved the filtering logic onto the block as a method.

  • Simplified the three-branch filter to one predicate: The three cases are all equivalent to checking is_git_provider_domain(hostname.unwrap_or(alias)) per alias.

  • Renamed parse_hosts_fromparse_hosts.

All existing tests pass unchanged. Let me know what you think!

@nathansobo nathansobo merged commit 3dd2e80 into zed-industries:main Mar 18, 2026
30 checks passed
@nathansobo
Copy link
Copy Markdown
Contributor

I'm gonna go ahead and merge this, but feel free to leave any feedback on my additions, and we can fix forward if there's anything I did that we want to change.

@nathansobo
Copy link
Copy Markdown
Contributor

By the way: Thanks so much!!!

@sarmadgulzar
Copy link
Copy Markdown
Contributor Author

@nathansobo looks good, thanks!

@sarmadgulzar sarmadgulzar deleted the fix/filter-git-providers-from-ssh-host-list branch March 19, 2026 13:09
@esthertrapadoux esthertrapadoux moved this to Shipped by the Guild in Zed Guild - The Board Mar 19, 2026
@JosephTLyons
Copy link
Copy Markdown
Collaborator

Thank you @sarmadgulzar!

AmaanBilwar pushed a commit to AmaanBilwar/zed that referenced this pull request Mar 20, 2026
…ries#51528)

Fixes zed-industries#50218

- For every `Host` block: collect its host patterns (handling
continuations and filtering `!`/`*/\`), remember any `Hostname`.
- When the block ends: if `Hostname` is a git provider → discard
everything.
- Else if `Hostname` exists → keep all host aliases.
- Else → keep only the host aliases that are not git providers.

Added more extensive test coverage as well to cover the above!

Release Notes:

- Fixed SSH host picker showing git provider domains (e.g. github.com,
gitlab.com) from SSH config.

---------

Co-authored-by: Nathan Sobo <nathan@zed.dev>
toshmukhamedov pushed a commit to toshmukhamedov/zed that referenced this pull request Mar 20, 2026
…ries#51528)

Fixes zed-industries#50218

- For every `Host` block: collect its host patterns (handling
continuations and filtering `!`/`*/\`), remember any `Hostname`.
- When the block ends: if `Hostname` is a git provider → discard
everything.
- Else if `Hostname` exists → keep all host aliases.
- Else → keep only the host aliases that are not git providers.

Added more extensive test coverage as well to cover the above!

Release Notes:

- Fixed SSH host picker showing git provider domains (e.g. github.com,
gitlab.com) from SSH config.

---------

Co-authored-by: Nathan Sobo <nathan@zed.dev>
AmaanBilwar pushed a commit to AmaanBilwar/zed that referenced this pull request Mar 23, 2026
…ries#51528)

Fixes zed-industries#50218

- For every `Host` block: collect its host patterns (handling
continuations and filtering `!`/`*/\`), remember any `Hostname`.
- When the block ends: if `Hostname` is a git provider → discard
everything.
- Else if `Hostname` exists → keep all host aliases.
- Else → keep only the host aliases that are not git providers.

Added more extensive test coverage as well to cover the above!

Release Notes:

- Fixed SSH host picker showing git provider domains (e.g. github.com,
gitlab.com) from SSH config.

---------

Co-authored-by: Nathan Sobo <nathan@zed.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions

Projects

Status: Shipped by the Guild

Development

Successfully merging this pull request may close these issues.

Remote Dev: github.com listed as SSH host, fails with confusing error

6 participants