c12be01a5f
packages/ai: - fix: hardened OpenAI tool-call JSON parsing for malformed trailing arguments - feat: routed GitHub Copilot Claude 4.x models through anthropic-messages - feat: centralized dynamic Copilot headers and anthropic bearer auth handling - feat: added optional StreamOptions.metadata propagation - test: added Copilot headers/auth/routing coverage - fix: updated model generator and models.json for Copilot Claude API mapping packages/coding-agent: - fix: made CLI model resolution deterministic with provider-aware pattern parsing - fix: corrected compaction boundary/context usage handling after compaction - feat: expanded extension events and terminal input hook integration - fix: hardened git source parsing to avoid local-path misclassification - test: added git-url parser coverage and model-resolver cases packages/tui: - fix: scoped @ fuzzy autocomplete to typed path prefixes - feat: added Windows VT input mode support via bun:ffi docs: - chore: updated porting sync point to 5133697
80 lines
2.2 KiB
TypeScript
80 lines
2.2 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { parseGitUrl } from "@oh-my-pi/pi-coding-agent/extensibility/plugins/git-url";
|
|
|
|
describe("parseGitUrl", () => {
|
|
describe("protocol URLs (accepted without git: prefix)", () => {
|
|
test("parses https URL", () => {
|
|
const result = parseGitUrl("https://github.com/user/repo");
|
|
expect(result).toMatchObject({
|
|
type: "git",
|
|
host: "github.com",
|
|
path: "user/repo",
|
|
repo: "https://github.com/user/repo",
|
|
pinned: false,
|
|
});
|
|
});
|
|
|
|
test("parses ssh URL", () => {
|
|
const result = parseGitUrl("ssh://git@github.com/user/repo");
|
|
expect(result).toMatchObject({
|
|
type: "git",
|
|
host: "github.com",
|
|
path: "user/repo",
|
|
repo: "ssh://git@github.com/user/repo",
|
|
pinned: false,
|
|
});
|
|
});
|
|
|
|
test("parses git protocol URL", () => {
|
|
const result = parseGitUrl("git://github.com/user/repo");
|
|
expect(result).toMatchObject({
|
|
type: "git",
|
|
host: "github.com",
|
|
path: "user/repo",
|
|
repo: "git://github.com/user/repo",
|
|
pinned: false,
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("shorthand URLs (accepted only with git: prefix)", () => {
|
|
test("parses host/path shorthand with git: prefix", () => {
|
|
const result = parseGitUrl("git:github.com/user/repo");
|
|
expect(result).toMatchObject({
|
|
type: "git",
|
|
host: "github.com",
|
|
path: "user/repo",
|
|
repo: "https://github.com/user/repo",
|
|
pinned: false,
|
|
});
|
|
});
|
|
|
|
test("parses scp-like ssh shorthand with git: prefix", () => {
|
|
const result = parseGitUrl("git:git@github.com:user/repo@v1.0.0");
|
|
expect(result).toMatchObject({
|
|
type: "git",
|
|
host: "github.com",
|
|
path: "user/repo",
|
|
repo: "git@github.com:user/repo",
|
|
ref: "v1.0.0",
|
|
pinned: true,
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("local paths and unprefixed shorthand", () => {
|
|
test("rejects unprefixed host/path shorthand", () => {
|
|
expect(parseGitUrl("github.com/user/repo")).toBeNull();
|
|
});
|
|
|
|
test("rejects unprefixed scp-like SSH shorthand", () => {
|
|
expect(parseGitUrl("git@github.com:user/repo")).toBeNull();
|
|
});
|
|
|
|
test("does not misclassify local paths containing dots", () => {
|
|
expect(parseGitUrl("plugins.v2/my-plugin")).toBeNull();
|
|
expect(parseGitUrl("vendor/github.enterprise/tools")).toBeNull();
|
|
});
|
|
});
|
|
});
|