Skip to content

Commit 7ad1c6e

Browse files
committed
fix: git clone with latest tagged commit
1 parent f4c1c47 commit 7ad1c6e

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

src/core/git.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from "node:fs/promises";
22
import path from "node:path";
3-
import simpleGit, { type SimpleGit } from "simple-git";
3+
import simpleGit from "simple-git";
44
import env from "./env";
55

66
function getRepoPath(serviceId: string) {
@@ -16,28 +16,16 @@ export async function cloneRepo(repoUrl: string, serviceId: string) {
1616
binary: "git",
1717
maxConcurrentProcesses: 6,
1818
});
19-
const latestTaggedCommitHash = await getLatestTaggedCommitHash(git, repoUrl);
2019
await git.clone(repoUrl, repoPath, {
2120
"--depth": "1",
2221
"--single-branch": null,
2322
"--branch": "main",
2423
});
25-
if (latestTaggedCommitHash) {
26-
await git.cwd(repoPath);
27-
await git.fetch("origin", latestTaggedCommitHash);
28-
}
24+
await git.cwd(repoPath);
25+
await git.fetch("--tags");
2926
return repoPath;
3027
}
3128

3229
export async function deleteRepo(serviceId: string) {
3330
await fs.rm(getRepoPath(serviceId), { recursive: true, force: true });
3431
}
35-
36-
async function getLatestTaggedCommitHash(git: SimpleGit, repoUrl: string) {
37-
const output = await git.listRemote(["--tags", repoUrl]);
38-
const entries = output.split("\n").slice(0, -1).map(entry => entry.split("\t"));
39-
const lastEntry = entries.at(-1);
40-
if (lastEntry && lastEntry.length === 2) {
41-
return lastEntry[0];
42-
}
43-
}

0 commit comments

Comments
 (0)