mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-05 16:04:43 +00:00
* fix(github): support repository lists from older gh versions GitHub CLI versions before 2.28 reject the visibility JSON field before returning repository data. Retry that specific failure with the older isPrivate field while preserving exact visibility on newer clients. * fix(github): stop requesting repository visibility Repository cloning does not use visibility. Leave the released response field optional and keep repository discovery on JSON fields supported by older GitHub CLI versions. * fix(github): keep the visibility enum on the wire, derive it from isPrivate Restores the required visibility enum in the search-repositories response schema. Omitting it broke old clients, which reject the whole response. The daemon still never asks gh for visibility -- that JSON field does not exist before gh 2.28 and Debian Bookworm ships 2.23. It asks for isPrivate, supported on every version, and maps it to public/private. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com> Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
135 lines
3.5 KiB
TypeScript
135 lines
3.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
createGitHubService,
|
|
type GitHubCommandRunner,
|
|
type GitHubCommandRunnerOptions,
|
|
} from "./github-service.js";
|
|
|
|
interface RunnerCall {
|
|
args: string[];
|
|
options: GitHubCommandRunnerOptions;
|
|
}
|
|
|
|
function createRunner(outputs: string[]): { calls: RunnerCall[]; runner: GitHubCommandRunner } {
|
|
const calls: RunnerCall[] = [];
|
|
return {
|
|
calls,
|
|
runner: async (args, options) => {
|
|
calls.push({ args, options });
|
|
return { stdout: outputs.shift() ?? "", stderr: "" };
|
|
},
|
|
};
|
|
}
|
|
|
|
describe("GitHub repository search", () => {
|
|
it("lists recent owned repositories for an empty query and normalizes clone identity", async () => {
|
|
const runner = createRunner([
|
|
JSON.stringify([
|
|
{
|
|
id: " R_recent ",
|
|
name: " paseo ",
|
|
nameWithOwner: " getpaseo/paseo ",
|
|
description: null,
|
|
isPrivate: false,
|
|
updatedAt: "2026-07-15T12:00:00Z",
|
|
sshUrl: " git@github.com:getpaseo/paseo.git ",
|
|
url: "https://github.com/getpaseo/paseo",
|
|
},
|
|
]),
|
|
"ssh\n",
|
|
]);
|
|
const service = createGitHubService({
|
|
runner: runner.runner,
|
|
resolveGhPath: async () => "/usr/bin/gh",
|
|
});
|
|
|
|
await expect(
|
|
service.searchRepositories({ cwd: "/tmp", query: " ", limit: 8 }),
|
|
).resolves.toEqual([
|
|
{
|
|
id: "R_recent",
|
|
name: "paseo",
|
|
nameWithOwner: "getpaseo/paseo",
|
|
description: null,
|
|
visibility: "public",
|
|
updatedAt: "2026-07-15T12:00:00Z",
|
|
cloneUrl: "git@github.com:getpaseo/paseo.git",
|
|
},
|
|
]);
|
|
expect(runner.calls).toEqual([
|
|
{
|
|
args: [
|
|
"repo",
|
|
"list",
|
|
"--json",
|
|
"id,name,nameWithOwner,description,isPrivate,updatedAt,sshUrl,url",
|
|
"--limit",
|
|
"8",
|
|
],
|
|
options: { cwd: "/tmp" },
|
|
},
|
|
{
|
|
args: ["config", "get", "git_protocol", "--host", "github.com"],
|
|
options: { cwd: "/tmp" },
|
|
},
|
|
]);
|
|
});
|
|
|
|
it("searches accessible repositories for a typed query", async () => {
|
|
const runner = createRunner([
|
|
JSON.stringify([
|
|
{
|
|
id: 42,
|
|
name: "private-repo",
|
|
fullName: "octo/private-repo",
|
|
description: "Private project",
|
|
isPrivate: true,
|
|
updatedAt: "2026-07-14T08:00:00Z",
|
|
url: "https://github.com/octo/private-repo",
|
|
},
|
|
]),
|
|
"https",
|
|
]);
|
|
const service = createGitHubService({
|
|
runner: runner.runner,
|
|
resolveGhPath: async () => "/usr/bin/gh",
|
|
});
|
|
|
|
await expect(
|
|
service.searchRepositories({ cwd: "/tmp", query: " private project ", limit: 5 }),
|
|
).resolves.toEqual([
|
|
{
|
|
id: "42",
|
|
name: "private-repo",
|
|
nameWithOwner: "octo/private-repo",
|
|
description: "Private project",
|
|
visibility: "private",
|
|
updatedAt: "2026-07-14T08:00:00Z",
|
|
cloneUrl: "https://github.com/octo/private-repo",
|
|
},
|
|
]);
|
|
expect(runner.calls).toEqual([
|
|
{
|
|
args: [
|
|
"search",
|
|
"repos",
|
|
"private project",
|
|
"--json",
|
|
"id,name,fullName,description,isPrivate,updatedAt,url",
|
|
"--sort",
|
|
"updated",
|
|
"--order",
|
|
"desc",
|
|
"--limit",
|
|
"5",
|
|
],
|
|
options: { cwd: "/tmp" },
|
|
},
|
|
{
|
|
args: ["config", "get", "git_protocol", "--host", "github.com"],
|
|
options: { cwd: "/tmp" },
|
|
},
|
|
]);
|
|
});
|
|
});
|