Skip to content

Resolve SSH host aliases in git remote URLs#857

Open
svarlamov wants to merge 1 commit intomainfrom
feat/ssh-alias-resolution
Open

Resolve SSH host aliases in git remote URLs#857
svarlamov wants to merge 1 commit intomainfrom
feat/ssh-alias-resolution

Conversation

@svarlamov
Copy link
Copy Markdown
Member

@svarlamov svarlamov commented Mar 29, 2026

Summary

  • Parse ~/.ssh/config to resolve SSH Host aliases to their HostName values when normalizing git remote URLs
  • Fixes telemetry/metrics reporting incorrect domains when repos use SSH profiles (e.g., git@github-work:org/repo now correctly resolves to github.com)
  • Always attempts resolution for any SSH-style URL — SSH aliases can be anything, including dotted hostnames

Changes

  • New src/ssh_config.rs: Lightweight SSH config parser (Host→HostName extraction, wildcard/Match block handling, case-insensitive keywords, = separator support)
  • src/repo_url.rs: normalize_repo_url() resolves SSH hosts via config for both scp-like and ssh:// URLs
  • src/authorship/git_ai_hooks.rs: Hook context now normalizes remote URLs (resolving aliases + canonicalizing)
  • 5 integration tests using TestRepo with isolated HOME/SSH config per test

Test plan

  • 15 unit tests for SSH config parser
  • 15 existing repo_url unit tests pass (no regression)
  • 5 new TestRepo-based e2e tests: alias resolution, no-config fallback, no-match fallback, dotted alias, multi-alias Host lines
  • 4 existing git_ai_hooks integration tests pass (no regression)
  • CI passes

🤖 Generated with Claude Code


Open with Devin

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

Base automatically changed from feat/remove-flush-logs-infra to main March 31, 2026 01:57
Parse ~/.ssh/config to resolve Host aliases to their HostName values
when normalizing git remote URLs. This fixes telemetry/metrics reporting
incorrect domains when repos use SSH profiles (e.g., git@github-work:org/repo
now correctly resolves to github.com instead of using "github-work" literally).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@svarlamov svarlamov force-pushed the feat/ssh-alias-resolution branch from 9a0606a to 9882dc6 Compare March 31, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant