Compare commits

...

9 Commits
master ... v

Author SHA1 Message Date
  gmarik 51d1bc60e4 Merge branch 'master' into v 12 years ago
  gmarik 191de1ffe7 support checking out specified revision 12 years ago
  gmarik 0debd50db3 when pulling use remote uri; also merge defaults 12 years ago
  gmarik 0925acd822 display Bundle's spec instead just name 12 years ago
  gmarik 49e4ca7bb7 do not override default opts 12 years ago
  gmarik a0124f066a use Vim's lcd to change directories 12 years ago
  gmarik 2d0909b816 name may have revision specified 12 years ago
  gmarik 5b4e238ad9 Bundle cmd may have 2 arguments only 12 years ago
  gmarik 45d5155c43 let options override 12 years ago
2 changed files with 45 additions and 17 deletions
Unified View
  1. +15
    -9
      autoload/vundle/config.vim
  2. +30
    -8
      autoload/vundle/installer.vim

+ 15
- 9
autoload/vundle/config.vim View File

@ -23,23 +23,29 @@ func! vundle#config#require(bundles) abort
endf endf
func! vundle#config#init_bundle(name, opts) func! vundle#config#init_bundle(name, opts)
let opts = extend(s:parse_options(a:opts), s:parse_name(substitute(a:name,"['".'"]\+','','g')))
let opts = extend(s:parse_options(a:opts), s:parse_name(substitute(a:name,"['".'"]\+','','g')), 'keep')
return extend(opts, copy(s:bundle)) return extend(opts, copy(s:bundle))
endf endf
func! s:parse_options(opts) func! s:parse_options(opts)
" TODO: improve this
if len(a:opts) != 1 | return {} | endif
if type(a:opts[0]) == type({})
" ignore everything except first argument
" which supposed to be option hash
if len(a:opts) == 1 && type(a:opts[0]) == type({})
return a:opts[0] return a:opts[0]
else
return {'rev': a:opts[0]}
endif endif
return {}
endf endf
func! s:parse_name(arg) func! s:parse_name(arg)
let arg = a:arg
let args = split(a:arg, '\s\+')
let arg = args[0]
let opts = {'spec': a:arg}
if len(args) == 2
let revision = args[1]
let opts['v'] = revision
end
if arg =~? '^\s*\(gh\|github\):\S\+' if arg =~? '^\s*\(gh\|github\):\S\+'
\ || arg =~? '^[a-z0-9][a-z0-9-]*/[^/]\+$' \ || arg =~? '^[a-z0-9][a-z0-9-]*/[^/]\+$'
let uri = 'https://github.com/'.split(arg, ':')[-1] let uri = 'https://github.com/'.split(arg, ':')[-1]
@ -53,7 +59,7 @@ func! s:parse_name(arg)
let name = arg let name = arg
let uri = 'https://github.com/vim-scripts/'.name.'.git' let uri = 'https://github.com/vim-scripts/'.name.'.git'
endif endif
return {'name': name, 'uri': uri }
return extend(opts, {'name': name, 'uri': uri })
endf endf
func! s:rtp_rm_a() func! s:rtp_rm_a()


+ 30
- 8
autoload/vundle/installer.vim View File

@ -11,7 +11,7 @@ func! vundle#installer#install(bang, ...) abort
let msg = 'No new bundles were installed' let msg = 'No new bundles were installed'
if (!empty(installed)) if (!empty(installed))
let msg = "Installed bundles:\n".join(map(installed, 'v:val.name'),"\n")
let msg = "Installed bundles:\n".join(map(installed, 'v:val.spec'),"\n")
endif endif
call s:log(msg) call s:log(msg)
@ -69,14 +69,11 @@ 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, 'skip'] | endif if !(a:bang) | return [0, 'skip'] | endif
let cmd = 'cd '.shellescape(a:bundle.path()).' && git pull'
if (has('win32') || has('win64'))
let cmd = substitute(cmd, '^cd ','cd /d ','') " add /d switch to change drives
let cmd = '"'.cmd.'"' " enclose in quotes
endif
lcd `=a:bundle.path()`
let cmd = 'git pull '.a:bundle.uri.' master:master'
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
@ -87,6 +84,25 @@ func! s:sync(bang, bundle) abort
echohl Error | echo 'Error installing "'.a:bundle.name.'". Failed cmd: '.cmd | echohl None echohl Error | echo 'Error installing "'.a:bundle.name.'". Failed cmd: '.cmd | echohl None
return [v:shell_error, 'error'] return [v:shell_error, 'error']
end end
" checkout revision
" master by default
let revision = 'master'
if has_key(a:bundle, 'v') && !empty(a:bundle['v'])
let revision = a:bundle['v']
end
lcd `=a:bundle.path()`
let cmd = 'git checkout '.revision
silent exec '!'.cmd
if 0 != v:shell_error
echohl Error | echo 'Error checking out "'.a:bundle.name.' '.revision.'". Failed cmd: '.cmd | echohl None
return [v:shell_error, 'error']
end
return [0, 'ok'] return [0, 'ok']
endf endf
@ -94,7 +110,13 @@ func! s:install(bang, bundles) abort
let [installed, errors] = [[],[]] let [installed, errors] = [[],[]]
for b in a:bundles for b in a:bundles
let [err_code, status] = s:sync(a:bang, b)
let cwd = getcwd()
try
let [err_code, status] = s:sync(a:bang, b)
finally
lcd `=cwd`
endtry
if 0 == err_code if 0 == err_code
if 'ok' == status | call add(installed, b) | endif if 'ok' == status | call add(installed, b) | endif
else else


Loading…
Cancel
Save