Skip to content

Commit 61b9233

Browse files
committed
feat: allow git+https://
1 parent 5081eaa commit 61b9233

File tree

6 files changed

+30
-4
lines changed

6 files changed

+30
-4
lines changed

deno.lock

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

git-mirror.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const cloneAction = async (options: CloneOptions, repo: string) => {
7979

8080
await new Command()
8181
.name("clone")
82-
.version("0.1.6")
82+
.version("0.1.7")
8383
.description("Clone/Fetch a Git repository into a 'Projects' directory")
8484
.arguments("<repo:string>")
8585
.option("-r, --root <rootDir>", "The root directory.", {

utils/file/get-dir-path-from-repo.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ describe("getDirPathFromRepo", () => {
1212
repo: "https://git-host.com/organisation/project.git",
1313
expected: "organisation/project",
1414
},
15+
{
16+
repo: "git+https://git-host.com/organisation/project.git",
17+
expected: "organisation/project",
18+
},
1519
];
1620

1721
for (const { repo, expected } of TEST_CASES) {

utils/file/get-dir-path-from-repo.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { colors } from "jsr:@cliffy/ansi@^1.0.0-rc.7/colors";
33
export const getDirPathFromRepo = (repo: string): string => {
44
let dirPath: string;
55

6-
if (repo.startsWith("git@")) {
6+
if (repo.startsWith("git+https://")) {
7+
const repoParts = repo.split("/");
8+
dirPath = repoParts.slice(3).join("/").replace(".git", "");
9+
} else if (repo.startsWith("git@")) {
710
const repoParts = repo.split(":");
811
dirPath = repoParts[1].replace(".git", "");
912
} else if (repo.startsWith("https://")) {

utils/file/get-host-from-repo.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ describe("getHostFromRepo", () => {
1212
repo: "https://git-host.com/organisation/project.git",
1313
expected: "git-host",
1414
},
15+
{
16+
repo: "git+https://git-host.com/organisation/project.git",
17+
expected: "git-host",
18+
},
1519
];
1620

1721
for (const { repo, expected } of TEST_CASES) {

utils/file/get-host-from-repo.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { colors } from "jsr:@cliffy/ansi@^1.0.0-rc.7/colors";
33
export const getHostFromRepo = (repo: string): string => {
44
let host: string;
55

6-
if (repo.startsWith("git@")) {
6+
if (repo.startsWith("git+https://")) {
7+
const repoParts = repo.split("/");
8+
host = repoParts[2].split(".")[0];
9+
} else if (repo.startsWith("git@")) {
710
const repoParts = repo.split(":");
811
host = repoParts[0].split("@")[1].split(".")[0];
912
} else if (repo.startsWith("https://")) {

0 commit comments

Comments
 (0)