@ -529,18 +529,26 @@ class Mirror(object):
' but failed. Continuing with non-optimized repository. '
' but failed. Continuing with non-optimized repository. '
% len ( pack_files ) )
% len ( pack_files ) )
def _fetch ( self , rundir , verbose , depth , no_fetch_tags , reset_fetch_config ) :
def _fetch ( self ,
rundir ,
verbose ,
depth ,
no_fetch_tags ,
reset_fetch_config ,
prune = True ) :
self . config ( rundir , reset_fetch_config )
self . config ( rundir , reset_fetch_config )
v = [ ]
d = [ ]
fetch_cmd = [ ' fetch ' ]
t = [ ]
if verbose :
if verbose :
v = [ ' -v ' , ' --progress ' ]
fetch_cmd. extend ( [ ' -v ' , ' --progress ' ] )
if depth :
if depth :
d = [ ' --depth ' , str ( depth ) ]
fetch_cmd. extend ( [ ' --depth ' , str ( depth ) ] )
if no_fetch_tags :
if no_fetch_tags :
t = [ ' --no-tags ' ]
fetch_cmd . append ( ' --no-tags ' )
fetch_cmd = [ ' fetch ' ] + v + d + t + [ ' origin ' ]
if prune :
fetch_cmd . append ( ' --prune ' )
fetch_cmd . append ( ' origin ' )
fetch_specs = subprocess . check_output (
fetch_specs = subprocess . check_output (
[ self . git_exe , ' config ' , ' --get-all ' , ' remote.origin.fetch ' ] ,
[ self . git_exe , ' config ' , ' --get-all ' , ' remote.origin.fetch ' ] ,
cwd = rundir ) . decode ( ' utf-8 ' , ' ignore ' ) . strip ( ) . splitlines ( )
cwd = rundir ) . decode ( ' utf-8 ' , ' ignore ' ) . strip ( ) . splitlines ( )
@ -574,16 +582,16 @@ class Mirror(object):
try :
try :
self . _ensure_bootstrapped ( depth , bootstrap , reset_fetch_config )
self . _ensure_bootstrapped ( depth , bootstrap , reset_fetch_config )
self . _fetch (
self . _fetch ( self . mirror_path , verbose , depth , no_fetch_tags ,
self . mirror_path , verbose , depth , no_fetch_tags , reset_fetch_config )
reset_fetch_config )
except ClobberNeeded :
except ClobberNeeded :
# This is a major failure, we need to clean and force a bootstrap.
# This is a major failure, we need to clean and force a bootstrap.
gclient_utils . rmtree ( self . mirror_path )
gclient_utils . rmtree ( self . mirror_path )
self . print ( GIT_CACHE_CORRUPT_MESSAGE )
self . print ( GIT_CACHE_CORRUPT_MESSAGE )
self . _ensure_bootstrapped (
self . _ensure_bootstrapped (
depth , bootstrap , reset_fetch_config , force = True )
depth , bootstrap , reset_fetch_config , force = True )
self . _fetch (
self . _fetch ( self . mirror_path , verbose , depth , no_fetch_tags ,
self . mirror_path , verbose , depth , no_fetch_tags , reset_fetch_config )
reset_fetch_config )
finally :
finally :
if not ignore_lock :
if not ignore_lock :
lockfile . unlock ( )
lockfile . unlock ( )