@ -201,50 +201,65 @@ func! s:helptags(rtp) abort
endf
func ! s :sync ( bang , bundle ) abort
call s :log ( '' )
call s :log ( 'Bundle ' .a :bundle .name_spec )
let git_dir = expand ( a :bundle .path ( ) .'/.git/' , 1 )
if isdirectory ( git_dir )
if ! ( a :bang ) | return 'todate' | endif
let cmd = 'cd ' .shellescape ( a :bundle .path ( ) ) .' && git pull'
let change_c md = 'cd ' .shellescape ( a :bundle .path ( ) )
if ( has ( 'win32' ) | | has ( 'win64' ) )
let cmd = substitute ( cmd , '^cd ' , 'cd /d ' , '' ) " add /d switch to change drives
let cmd = '"' .cmd .'"' " enclose in quotes
let change_cmd = substitute ( change_cmd , '^cd ' , 'cd /d ' , '' ) " add /d switch to change drives
let change_cmd = '"' .change_cmd .'"' " enclose in quotes
endif
let cmd = change_cmd .' && git rev-parse HEAD'
let initial_sha = s :system ( cmd )
if 0 ! = v :shell_error | return 'error' | endif
let cmd = change_cmd .' && git pull'
let out = s :system ( cmd )
call s :log ( '$ ' .cmd )
call s :log ( '> ' .out )
if 0 ! = v :shell_error | return 'error' | endif
let cmd = change_cmd .' && git rev-parse HEAD'
let updated_sha = s :system ( cmd )
if 0 ! = v :shell_error | return 'error' | endif
let initial_sha = s :strip_right ( initial_sha )
let updated_sha = s :strip_right ( updated_sha )
if initial_sha = = updated_sha
return 'todate'
endif
call add ( g :updated_bundles , [initial_sha , updated_sha , a :bundle ])
return 'updated'
else
let cmd = 'git clone ' .a :bundle .uri .' ' .shellescape ( a :bundle .path ( ) )
endif
let out = s :system ( cmd )
call s :log ( '' )
call s :log ( 'Bundle ' .a :bundle .name_spec )
call s :log ( '$ ' .cmd )
call s :log ( '> ' .out )
let out = s :system ( cmd )
call s :log ( '$ ' .cmd )
call s :log ( '> ' .out )
if 0 ! = v :shell_error
return 'error'
end
if 0 ! = v :shell_error | return 'error' | endif
if out = ~ # 'Cloning into '
return 'new'
elseif out = ~ # 'up-to-date'
return 'todate'
endif
call s :add_to_updated_bundles ( out , a :bundle )
return 'updated'
endf
func ! s :system ( cmd ) abort
return system ( a :cmd )
endf
func ! s :add_to_updated_bundles ( out , bundle ) abort
let git_pull_shas = matchlist ( a :out , 'Updating \(\w\+\)..\(\w\+\)' )
let initial_sha = git_pull_shas [1 ]
let updated_sha = git_pull_shas [2 ]
call add ( g :updated_bundles , [initial_sha , updated_sha , a :bundle ])
endfunc
func ! s :strip_right ( input )
return substitute ( a :input , '[[:space:][:cntrl:]]\+$' , '' , '' )
endfunction
func ! s :log ( str ) abort
let fmt = '%y%m%d %H:%M:%S'