fix: refresh repository identity after SSH translation - #274
Open
benekuehn wants to merge 1 commit into
Open
Conversation
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.
This was referenced Jul 30, 2026
benekuehn
marked this pull request as ready for review
July 30, 2026 12:14
|
Request to merge this urgently Quite a common usecase for users with multiple github accounts |
Contributor
There was a problem hiding this comment.
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
translateRemotesand refreshesRemote{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
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.
Summary
Root cause
repository.Currenttranslated the fetch and push URLs, but the cachedHost,Owner, andRepofields 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
gh stack submitfails when remote uses a custom SSH host alias github/gh-stack#45gh stack submitgithub/gh-stack#337