Skip to content

fix: refresh repository identity after SSH translation - #274

Open
benekuehn wants to merge 1 commit into
cli:trunkfrom
benekuehn:fix/repository-ssh-alias
Open

fix: refresh repository identity after SSH translation#274
benekuehn wants to merge 1 commit into
cli:trunkfrom
benekuehn:fix/repository-ssh-alias

Conversation

@benekuehn

Copy link
Copy Markdown

Summary

  • refresh cached remote metadata after resolving SSH host aliases
  • preserve fetch URL precedence, falling back to push metadata when the fetch URL cannot be parsed

Root cause

repository.Current translated the fetch and push URLs, but the cached Host, Owner, and Repo fields still described the pre-translation URL. Known-host filtering therefore rejected remotes that used SSH aliases for GitHub.

Testing

  • go test ./...
  • go vet ./...

Related issues

Refresh cached remote metadata after translating SSH host aliases. Preserve go-gh's fetch-then-push fallback when extracting repository identity.

Relates to github/gh-stack#45 and github/gh-stack#337.
@benekuehn
benekuehn marked this pull request as ready for review July 30, 2026 12:14
@benekuehn
benekuehn requested a review from a team as a code owner July 30, 2026 12:14
@benekuehn
benekuehn requested review from tidy-dev and removed request for a team July 30, 2026 12:14
@RishabJaiswal

Copy link
Copy Markdown

Request to merge this urgently

Quite a common usecase for users with multiple github accounts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes incorrect remote host/owner/repo identity caching when SSH hostname aliases are translated, ensuring host-based filtering works against the post-translation canonical hostname (e.g., github.com).

Changes:

  • Refactors SSH URL translation into translateRemotes and refreshes Remote{Host,Owner,Repo} after translation.
  • Preserves fetch URL metadata precedence, falling back to push URL metadata only when fetch repo info cannot be derived.
  • Adds unit tests covering SSH alias translation and the fetch-to-push fallback behavior.
Show a summary per file
File Description
pkg/repository/repository.go Translates remotes via a helper and refreshes cached remote identity fields after SSH alias resolution, with fetch-first fallback semantics.
pkg/repository/repository_test.go Adds tests validating remote identity refresh after translation and fallback to push URL when fetch repo info is invalid.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

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.

3 participants