diff --git a/autoload/vundle/config.vim b/autoload/vundle/config.vim index ee1e42b..b75ed3d 100644 --- a/autoload/vundle/config.vim +++ b/autoload/vundle/config.vim @@ -24,24 +24,29 @@ func! vundle#config#require(bundles) abort endf 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)) endf 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] - else - return {'rev': a:opts[0]} endif + return {} endf func! s:parse_name(arg) - let arg = a:arg let git_proto = exists('g:vundle_default_git_proto') ? g:vundle_default_git_proto : 'https' + let args = split(a:arg, '\s\+') + let arg = args[0] + + " Bundle 'gmarik/vundle v0.8' + if len(args) == 2 + let revision = args[1] + let opts['v'] = revision + end if arg =~? '^\s*\(gh\|github\):\S\+' \ || arg =~? '^[a-z0-9][a-z0-9-]*/[^/]\+$' @@ -59,7 +64,8 @@ func! s:parse_name(arg) let name = arg let uri = git_proto.'://github.com/vim-scripts/'.name.'.git' endif - return {'name': name, 'uri': uri, 'name_spec': arg } + + return extend(opts, {'name': name, 'uri': uri, 'name_spec': arg }) endf func! s:rtp_rm_a() diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index 0f71ebf..e493d15 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -196,9 +196,16 @@ endf func! s:sync(bang, bundle) abort let git_dir = expand(a:bundle.path().'/.git/', 1) + + let revision = 'master' + + if has_key(a:bundle, 'v') && !empty(a:bundle['v']) + let revision = a:bundle['v'] + end + if isdirectory(git_dir) if !(a:bang) | return 'todate' | endif - let cmd = 'cd '.shellescape(a:bundle.path()).' && git pull' + let cmd = 'cd '.shellescape(a:bundle.path()).' && git pull '.a:bundle.uri.' '.revision.':'.revision if (has('win32') || has('win64')) let cmd = substitute(cmd, '^cd ','cd /d ','') " add /d switch to change drives @@ -222,6 +229,24 @@ func! s:sync(bang, bundle) abort return 'todate' end + +" " checkout revision +" " master by default +" +" 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'] +" endf + + return 'updated' endf