Merge branch 'errs'

This commit is contained in:
gmarik 2011-07-15 02:16:13 -05:00
commit c411a207b4
3 changed files with 45 additions and 21 deletions

View File

@ -4,14 +4,16 @@ func! vundle#installer#install(bang, ...) abort
\ s:reload_bundles() : \ s:reload_bundles() :
\ map(copy(a:000), 'vundle#config#init_bundle(v:val, {})') \ map(copy(a:000), 'vundle#config#init_bundle(v:val, {})')
let installed = s:install(a:bang, bundles) let [installed, errors] = s:install(a:bang, bundles)
redraw! if empty(errors) | redraw! | end
" TODO: handle error: let user know hen they need to restart Vim " TODO: handle error: let user know hen they need to restart Vim
call vundle#config#require(bundles) call vundle#config#require(bundles)
call s:log("Installed bundles:\n".join((empty(installed) ? let msg = 'No new bundles were installed'
\ ['no new bundles installed'] : if (!empty(installed))
\ map(installed, 'v:val.name')),"\n")) let msg = "Installed bundles:\n".join(map(installed, 'v:val.name'),"\n")
endif
call s:log(msg)
call vundle#installer#helptags(bundles) call vundle#installer#helptags(bundles)
endf endf
@ -21,7 +23,7 @@ func! vundle#installer#helptags(bundles) abort
let help_dirs = filter(bundle_dirs, 's:has_doc(v:val)') let help_dirs = filter(bundle_dirs, 's:has_doc(v:val)')
call map(copy(help_dirs), 's:helptags(v:val)') call map(copy(help_dirs), 's:helptags(v:val)')
if !empty(help_dirs) if !empty(help_dirs)
call s:log('Helptags: done. '.len(help_dirs).' bundles processed') call s:log('Helptags: '.len(help_dirs).' bundles processed')
endif endif
return help_dirs return help_dirs
endf endf
@ -68,7 +70,7 @@ endf
func! s:sync(bang, bundle) abort func! s:sync(bang, bundle) abort
let git_dir = expand(a:bundle.path().'/.git/') let git_dir = expand(a:bundle.path().'/.git/')
if isdirectory(git_dir) if isdirectory(git_dir)
if !(a:bang) | return 0 | endif if !(a:bang) | return [0, 'skip'] | endif
let cmd = 'cd '.shellescape(a:bundle.path()).' && git pull' let cmd = 'cd '.shellescape(a:bundle.path()).' && git pull'
if (has('win32') || has('win64')) if (has('win32') || has('win64'))
@ -78,12 +80,28 @@ func! s:sync(bang, bundle) abort
else else
let cmd = 'git clone '.a:bundle.uri.' '.shellescape(a:bundle.path()) let cmd = 'git clone '.a:bundle.uri.' '.shellescape(a:bundle.path())
endif endif
silent exec '!'.cmd silent exec '!'.cmd
return 1
if 0 != v:shell_error
echohl Error | echo 'Error installing "'.a:bundle.name.'". Failed cmd: '.cmd | echohl None
return [v:shell_error, 'error']
end
return [0, 'ok']
endf endf
func! s:install(bang, bundles) abort func! s:install(bang, bundles) abort
return filter(copy(a:bundles), 's:sync(a:bang, v:val)') let [installed, errors] = [[],[]]
for b in a:bundles
let [err_code, status] = s:sync(a:bang, b)
if 0 == err_code
if 'ok' == status | call add(installed, b) | endif
else
call add(errors, b)
endif
endfor
return [installed, errors]
endf endf
" TODO: make it pause after output in console mode " TODO: make it pause after output in console mode

View File

@ -12,6 +12,7 @@ func! vundle#scripts#all(bang, ...)
setl hls setl hls
let b:match = a:1 let b:match = a:1
endif endif
redraw!
echo len(matches).' bundles found' echo len(matches).' bundles found'
endf endf
@ -60,24 +61,26 @@ func! s:display(headers, results)
endf endf
func! s:fetch_scripts(to) func! s:fetch_scripts(to)
let temp = shellescape(tempname()) let scripts_dir = fnamemodify(expand(a:to), ":h")
if has('win32') || has('win64') if !isdirectory(scripts_dir)
let scripts_dir = fnamemodify(expand(a:to), ":h") call mkdir(scripts_dir, "p")
if !isdirectory(scripts_dir)
call mkdir(scripts_dir, "p")
endif
exec '!curl http://vim-scripts.org/api/scripts.json > '.temp.
\ '&& move /Y '.temp.' '.shellescape(a:to)
else
exec '!curl http://vim-scripts.org/api/scripts.json > '.temp.
\ '&& mkdir -p $(dirname '.shellescape(a:to).') && mv -f '.temp.' '.shellescape(a:to)
endif endif
silent exec '!curl --fail -s -o '.shellescape(a:to).' http://vim-scripts.org/api/scripts.json'
if (0 != v:shell_error)
echoerr 'Error fetching scripts!'
return v:shell_error
endif
return 0
endf endf
func! s:load_scripts(bang) func! s:load_scripts(bang)
let f = expand('$HOME/.vim-vundle/vim-scripts.org.json') let f = expand('$HOME/.vim-vundle/vim-scripts.org.json')
if a:bang || !filereadable(f) if a:bang || !filereadable(f)
call s:fetch_scripts(f) if 0 != s:fetch_scripts(f)
return []
end
endif endif
return eval(readfile(f, 'b')[0]) return eval(readfile(f, 'b')[0])
endf endf

View File

@ -30,6 +30,9 @@ Bundle 'vim-scripts/ragtag.vim'
Bundle 'altercation/vim-colors-solarized' Bundle 'altercation/vim-colors-solarized'
" with extension " with extension
Bundle 'nelstrom/vim-mac-classic-theme.git' Bundle 'nelstrom/vim-mac-classic-theme.git'
"
" invalid uri
Bundle 'nonexistinguser/yupppierepo.git'
" full uri " full uri
Bundle 'https://github.com/vim-scripts/vim-game-of-life' Bundle 'https://github.com/vim-scripts/vim-game-of-life'