def update_git_repos(opts=None, clean=False, masterless=False):
 if (opts is None):
  opts = __opts__
 winrepo_dir = opts['winrepo_dir']
 winrepo_remotes = opts['winrepo_remotes']
 winrepo_cfg = [(winrepo_remotes, winrepo_dir), (opts['winrepo_remotes_ng'], opts['winrepo_dir_ng'])]
 ret = {}
 for (remotes, base_dir) in winrepo_cfg:
  if (not any((salt.utils.gitfs.HAS_GITPYTHON, salt.utils.gitfs.HAS_PYGIT2))):
   winrepo_result = {}
   for remote_info in remotes:
    if ('/' in remote_info):
     targetname = remote_info.split('/')[(-1)]
    else:
     targetname = remote_info
    rev = 'HEAD'
    try:
     (rev, remote_url) = remote_info.strip().split()
    except ValueError:
     remote_url = remote_info
    gittarget = os.path.join(base_dir, targetname).replace('.', '_')
    if masterless:
     result = __salt__['state.single']('git.latest', name=remote_url, rev=rev, branch='winrepo', target=gittarget, force_checkout=True, force_reset=True)
     if isinstance(result, list):
      raise CommandExecutionError('Failed up update winrepo remotes: {0}'.format('\n'.join(result)))
     if ('name' not in result):
      key = next(iter(result))
      result = result[key]
    else:
     mminion = salt.minion.MasterMinion(opts)
     result = mminion.states['git.latest'](remote_url, rev=rev, branch='winrepo', target=gittarget, force_checkout=True, force_reset=True)
    winrepo_result[result['name']] = result['result']
   ret.update(winrepo_result)
  else:
   try:
    winrepo = salt.utils.gitfs.WinRepo(opts, base_dir)
    winrepo.init_remotes(remotes, PER_REMOTE_OVERRIDES)
    winrepo.fetch_remotes()
    if clean:
     winrepo.clear_old_remotes()
    winrepo.checkout()
   except Exception as exc:
    msg = 'Failed to update winrepo_remotes: {0}'.format(exc)
    log.error(msg, exc_info_on_loglevel=logging.DEBUG)
    return msg
   ret.update(winrepo.winrepo_dirs)
 return ret

def update_git_repos ( opts = None , clean = False , masterless = False ) : if ( opts is None ) : opts = __opts__ winrepo_dir = opts [ 'winrepo_dir' ] winrepo_remotes = opts [ 'winrepo_remotes' ] winrepo_cfg = [ ( winrepo_remotes , winrepo_dir ) , ( opts [ 'winrepo_remotes_ng' ] , opts [ 'winrepo_dir_ng' ] ) ] ret = { } for ( remotes , base_dir ) in winrepo_cfg : if ( not any ( ( salt . utils . gitfs . HAS_GITPYTHON , salt . utils . gitfs . HAS_PYGIT2 ) ) ) : winrepo_result = { } for remote_info in remotes : if ( '/' in remote_info ) : targetname = remote_info . split ( '/' ) [ ( - 1 ) ] else : targetname = remote_info rev = 'HEAD' try : ( rev , remote_url ) = remote_info . strip ( ) . split ( ) except ValueError : remote_url = remote_info gittarget = os . path . join ( base_dir , targetname ) . replace ( '.' , '_' ) if masterless : result = __salt__ [ 'state.single' ] ( 'git.latest' , name = remote_url , rev = rev , branch = 'winrepo' , target = gittarget , force_checkout = True , force_reset = True ) if isinstance ( result , list ) : raise CommandExecutionError ( 'Failed up update winrepo remotes: {0}' . format ( '\n' . join ( result ) ) ) if ( 'name' not in result ) : key = next ( iter ( result ) ) result = result [ key ] else : mminion = salt . minion . MasterMinion ( opts ) result = mminion . states [ 'git.latest' ] ( remote_url , rev = rev , branch = 'winrepo' , target = gittarget , force_checkout = True , force_reset = True ) winrepo_result [ result [ 'name' ] ] = result [ 'result' ] ret . update ( winrepo_result ) else : try : winrepo = salt . utils . gitfs . WinRepo ( opts , base_dir ) winrepo . init_remotes ( remotes , PER_REMOTE_OVERRIDES ) winrepo . fetch_remotes ( ) if clean : winrepo . clear_old_remotes ( ) winrepo . checkout ( ) except Exception as exc : msg = 'Failed to update winrepo_remotes: {0}' . format ( exc ) log . error ( msg , exc_info_on_loglevel = logging . DEBUG ) return msg ret . update ( winrepo . winrepo_dirs ) return ret
checkout git repos containing :ref:windows software package definitions <windows-package-manager> .