Skip to content

Commit 817a209

Browse files
authored
Merge pull request #666 from hyoo-ru/builder-fix
$mol_build fix git pull
2 parents 2b7ae8c + edf0750 commit 817a209

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

build/build.node.ts

+18-4
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,21 @@ namespace $ {
591591
return {}
592592
}
593593
}
594+
595+
@ $mol_mem
596+
gitVersion() {
597+
return this.$.$mol_exec('.', 'git', 'version').stdout?.toString().trim().match(/.*\s+([\d\.]+)$/)?.[1] ?? ''
598+
}
599+
600+
gitDeepenSupported() {
601+
return $mol_compare_text()(this.gitVersion(), '2.42.0') >= 0
602+
}
603+
604+
gitPull(path: string) {
605+
const args = [ 'pull' ]
606+
if (this.gitDeepenSupported()) args.push('--deepen=1')
607+
return this.$.$mol_exec( path , 'git', ...args)
608+
}
594609

595610
@ $mol_mem_key
596611
modEnsure( path : string ) {
@@ -612,9 +627,8 @@ namespace $ {
612627
if( mod.type() !== 'dir' ) return false
613628

614629
const git_dir = mod.resolve( '.git' )
615-
if( git_dir.exists() ) {
616-
617-
this.$.$mol_exec( mod.path() , 'git' , 'pull', '--depth=1' )
630+
if( git_dir.exists() && git_dir.type() === 'dir') {
631+
this.gitPull( mod.path() )
618632
// mod.reset()
619633
// for ( const sub of mod.sub() ) sub.reset()
620634

@@ -632,7 +646,7 @@ namespace $ {
632646
: matched[1]
633647

634648
this.$.$mol_exec( mod.path() , 'git' , 'remote' , 'add' , '--track' , head_branch_name! , 'origin' , repo.text() )
635-
this.$.$mol_exec( mod.path() , 'git' , 'pull', '--deepen=1' )
649+
this.gitPull( mod.path() )
636650
mod.reset()
637651
for ( const sub of mod.sub() ) {
638652
sub.reset()

0 commit comments

Comments
 (0)