11import fs from "node:fs/promises" ;
22import path from "node:path" ;
3- import simpleGit , { type SimpleGit } from "simple-git" ;
3+ import simpleGit from "simple-git" ;
44import env from "./env" ;
55
66function 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
3229export 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