Permalink
Browse files

Return bundle status without using git output text

Instead checking for specific text in the output of the git commands, determine
the status of the bundle by comparing the sha of HEAD before and after the
git pull command.
  • Loading branch information...
1 parent d62b51a commit e56d772ecf6ed75480a50b39332f720fe9af86b0 @zolrath zolrath committed Apr 20, 2012
Showing with 11 additions and 14 deletions.
  1. +11 −14 autoload/vundle/installer.vim
@@ -212,8 +212,12 @@ func! s:sync(bang, bundle) abort
let cmd = substitute(cmd, '^cd ','cd /d ','') " add /d switch to change drives
let cmd = '"'.cmd.'"' " enclose in quotes
endif
+
+ let get_current_sha = 'cd '.shellescape(a:bundle.path()).' && git rev-parse HEAD'
+ let initial_sha = s:system(get_current_sha)[0:15]
else
let cmd = 'git clone '.a:bundle.uri.' '.shellescape(a:bundle.path())
+ let initial_sha = ''
endif
let out = s:system(cmd)
@@ -226,31 +230,24 @@ func! s:sync(bang, bundle) abort
return 'error'
end
- if out =~# 'Cloning into '
+ if empty(initial_sha)
return 'new'
- elseif out =~# 'up-to-date'
+ endif
+
+ let updated_sha = s:system(get_current_sha)[0:15]
+
+ if initial_sha == updated_sha
return 'todate'
endif
- call s:add_to_updated_bundles(out, a:bundle)
+ call add(g:updated_bundles, [initial_sha, updated_sha, 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\+\)')
-
- if (empty(git_pull_shas)) | return | endif
-
- 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:log(str) abort
let fmt = '%y%m%d %H:%M:%S'
call add(g:vundle_log, '['.strftime(fmt).'] '.a:str)

0 comments on commit e56d772

Please sign in to comment.