/ opencodehub / cli / src / lib / git.test.ts
Swadhin Biswas feat(cli): expand command coverage and config support · 3/6/2026
7e372c1
23 lines · 641 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { describe, expect, it } from "vitest";
import { parseRepoFromRemoteUrl } from "./git.js";

describe("parseRepoFromRemoteUrl", () => {
  it("parses https remotes", () => {
    expect(parseRepoFromRemoteUrl("https://git.example.com/acme/platform.git")).toEqual({
      owner: "acme",
      repo: "platform",
    });
  });

  it("parses ssh remotes", () => {
    expect(parseRepoFromRemoteUrl("[email protected]:acme/platform.git")).toEqual({
      owner: "acme",
      repo: "platform",
    });
  });

  it("returns null for invalid remote format", () => {
    expect(parseRepoFromRemoteUrl("git.example.com")).toBeNull();
  });
});