mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-08 08:52:12 +00:00
Clone Repository gets IntelliJ's layout: a source list on the left, a version-control selector, URL history, a directory picker, and a shallow-clone option (history truncated to N commits, git clone --depth N). Entries for hosting platforms without backend support were removed. Co-authored-by: whyareyouserious <[email protected]>
51 lines
2.1 KiB
TypeScript
51 lines
2.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { cloneDirName, joinPath, parseCloneDepth, validateClone } from "../clone";
|
|
import { outgoingQuery } from "../remoteUi";
|
|
|
|
describe("cloneDirName", () => {
|
|
it("derives the folder git would create", () => {
|
|
expect(cloneDirName("https://github.com/user/repo.git")).toBe("repo");
|
|
expect(cloneDirName("https://github.com/user/repo")).toBe("repo");
|
|
expect(cloneDirName("https://github.com/user/repo/")).toBe("repo");
|
|
expect(cloneDirName("[email protected]:user/my-lib.git")).toBe("my-lib");
|
|
expect(cloneDirName("ssh://git@host:2222/group/sub/proj.git")).toBe("proj");
|
|
expect(cloneDirName("/srv/git/local.git/")).toBe("local");
|
|
expect(cloneDirName("https://host/a/b.git?ref=x")).toBe("b");
|
|
expect(cloneDirName(" ")).toBe("");
|
|
});
|
|
});
|
|
|
|
describe("joinPath / validateClone", () => {
|
|
it("joins with a single separator", () => {
|
|
expect(joinPath("/Users/me/dev/", "repo")).toBe("/Users/me/dev/repo");
|
|
expect(joinPath("", "repo")).toBe("repo");
|
|
expect(joinPath("/x", "")).toBe("/x");
|
|
});
|
|
it("requires a URL and an absolute directory", () => {
|
|
expect(validateClone("", "/a")).toMatch(/URL/);
|
|
expect(validateClone("--upload-pack=x", "/a")).toMatch(/Invalid/);
|
|
expect(validateClone("https://h/r a", "/a")).toMatch(/spaces/);
|
|
expect(validateClone("https://h/r", "")).toMatch(/directory/i);
|
|
expect(validateClone("https://h/r", "rel/dir")).toMatch(/absolute/);
|
|
expect(validateClone("https://h/r", "/abs/r")).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe("parseCloneDepth", () => {
|
|
it("accepts positive Git depths only", () => {
|
|
expect(parseCloneDepth("1")).toBe(1);
|
|
expect(parseCloneDepth(" 25 ")).toBe(25);
|
|
expect(parseCloneDepth("0")).toBeNull();
|
|
expect(parseCloneDepth("1.5")).toBeNull();
|
|
expect(parseCloneDepth("abc")).toBeNull();
|
|
expect(parseCloneDepth("4294967296")).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe("outgoingQuery", () => {
|
|
it("uses the upstream range when tracked", () => {
|
|
expect(outgoingQuery("origin/main")).toEqual({ branch: "HEAD", range: "@{u}..HEAD", limit: 1000 });
|
|
expect(outgoingQuery(null).range).toBeNull();
|
|
});
|
|
});
|