Support GitHub SSH host aliases for PR actions

Resolves the case where a remote like `git@github-work:owner/repo.git`
points at github.com via `~/.ssh/config` but Paseo treats it as
non-GitHub.

Adds a centralized GitHub remote resolver that parses standard remotes
directly and resolves SSH aliases via `ssh -G` (with hostname
validation to keep the alias out of ssh's option parser). The resolver
is shared by workspace GitHub feature detection, PR status, PR
creation, and workspace git metadata.
This commit is contained in:
Jakub Skałecki
2026-04-27 20:28:10 +08:00
committed by GitHub
parent ec4f569f6e
commit ee5a23d962
10 changed files with 377 additions and 158 deletions
@@ -1,3 +1,7 @@
import { execFileSync } from "node:child_process";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import {
GitHubAuthenticationError,
@@ -1837,16 +1841,20 @@ describe("GitHubService", () => {
expect(valid.reason).toBe("test");
});
it("resolves GitHub repos from a WorkspaceGitService-owned remote URL", async () => {
const workspaceGitService = {
resolveRepoRemoteUrl: async (cwd: string) => {
expect(cwd).toBe("/repo");
return "git@github.com:getpaseo/paseo.git";
},
};
it("resolves GitHub repos from the origin remote URL", async () => {
vi.useRealTimers();
const cwd = mkdtempSync(join(tmpdir(), "github-service-repo-"));
await expect(resolveGitHubRepo("/repo", { workspaceGitService })).resolves.toBe(
"getpaseo/paseo",
);
try {
execFileSync("git", ["init", "-b", "main"], { cwd, stdio: "ignore" });
execFileSync("git", ["remote", "add", "origin", "git@github.com:getpaseo/paseo.git"], {
cwd,
stdio: "ignore",
});
await expect(resolveGitHubRepo(cwd)).resolves.toBe("getpaseo/paseo");
} finally {
rmSync(cwd, { recursive: true, force: true });
}
});
});