opencode
opencode copied to clipboard
fix(cli): support SSH aliases when installing opencode GitHub app
What does this PR do?
Fixes https://github.com/anomalyco/opencode/issues/9317.
The fix consists of running ssh -G alias to resolve the alias and find the hostname configured in the .ssh/config file. If said hostname is github.com, then proceed with the installation. Otherwise, raise the existing error.
Fix description
- Run
git remote get-url origin. a. If the output containsgithub.comas a hostname, install the app. b. If not, continue with the alias resolution. - Run
ssh -G aliasto resolve the alias. - Extract the hostname from the output of
ssh -G alias. - Verify the hostname is
github.com. a. If it matches, proceed with the installation. b. If it doesn't match, raise the existing error.
The existing behaviour remains if no alias is used.
Fix screenshot
How did you verify your code works?
Manual verification by running bun dev github install on a repo. Also, added unit tests to ensure the behavior is as expected.
How to verify the fix?
Set up a ssh alias as described in https://github.com/anomalyco/opencode/issues/9317. Then, clone a repo using the alias. Finally, run opencode github install in said repo.