@@ -591,6 +591,21 @@ namespace $ {
591
591
return { }
592
592
}
593
593
}
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
+ }
594
609
595
610
@ $mol_mem_key
596
611
modEnsure ( path : string ) {
@@ -612,9 +627,8 @@ namespace $ {
612
627
if ( mod . type ( ) !== 'dir' ) return false
613
628
614
629
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 ( ) )
618
632
// mod.reset()
619
633
// for ( const sub of mod.sub() ) sub.reset()
620
634
@@ -632,7 +646,7 @@ namespace $ {
632
646
: matched [ 1 ]
633
647
634
648
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 ( ) )
636
650
mod . reset ( )
637
651
for ( const sub of mod . sub ( ) ) {
638
652
sub . reset ( )
0 commit comments