Browse Source

Merge branch 'nosync' into events

Conflicts:
	autoload/vundle/config.vim
	autoload/vundle/installer.vim
	test/vimrc
events
gmarik 15 years ago
parent
commit
f4a15996cf
6 changed files with 100 additions and 23 deletions
  1. +12
    -0
      README.md
  2. +2
    -2
      autoload/vundle.vim
  3. +30
    -11
      autoload/vundle/config.vim
  4. +4
    -5
      autoload/vundle/installer.vim
  5. +3
    -0
      test/plugin/test_plugin.vim
  6. +49
    -5
      test/vimrc

+ 12
- 0
README.md View File

@ -68,6 +68,18 @@ see [`:h vundle`](vundle/blob/master/doc/vundle.txt#L1) vimdoc for more details.
See [gmarik's vimrc](https://github.com/gmarik/vimfiles/blob/1f4f26d42f54443f1158e0009746a56b9a28b053/vimrc#L136) for working example. See [gmarik's vimrc](https://github.com/gmarik/vimfiles/blob/1f4f26d42f54443f1158e0009746a56b9a28b053/vimrc#L136) for working example.
## FAQ
- **Q** i'm aked for username/pass, why?
**A** Correct invalid bundle name.
this is the case of invalid name used with `Bundle`, which leads to attemt to clone nonexisting repo:
git clone http://github.com/gmarik/non_existin_repo
Cloning into non_existin_repo...
Username:
Password:
fatal: Authentication failed
## Contributors ## Contributors
* [redlinesoftware](http://redlinesoftware.com) - for lending me 24" monitor! * [redlinesoftware](http://redlinesoftware.com) - for lending me 24" monitor!


+ 2
- 2
autoload/vundle.vim View File

@ -4,8 +4,8 @@
" Readme: http://github.com/gmarik/vundle/blob/master/README.md " Readme: http://github.com/gmarik/vundle/blob/master/README.md
" Version: 0.8 " Version: 0.8
com! -nargs=+ Bundle
\ call vundle#config#bundle(<args>)
com! -nargs=+ -bang Bundle
\ call vundle#config#bundle('!' == '<bang>', <args>)
com! -nargs=? -bang -complete=custom,vundle#scripts#complete BundleInstall com! -nargs=? -bang -complete=custom,vundle#scripts#complete BundleInstall
\ call vundle#installer#install('!' == '<bang>', <q-args>) \ call vundle#installer#install('!' == '<bang>', <q-args>)


+ 30
- 11
autoload/vundle/config.vim View File

@ -1,5 +1,5 @@
func! vundle#config#bundle(arg, ...)
let bundle = vundle#config#init_bundle(a:arg, a:000)
func! vundle#config#bundle(bang, arg, ...) abort
let bundle = vundle#config#init_bundle(a:bang, a:arg, a:000)
call s:rtp_rm_a() call s:rtp_rm_a()
call add(g:vundle#bundles, bundle) call add(g:vundle#bundles, bundle)
call s:rtp_add_a() call s:rtp_add_a()
@ -22,20 +22,25 @@ func! vundle#config#require(bundles) abort
endfor endfor
endf endf
func! vundle#config#init_bundle(name, opts)
let opts = extend(s:parse_options(a:opts), s:parse_name(substitute(a:name,"['".'"]\+','','g')))
func! vundle#config#init_bundle(bang, name, opts)
let opts = extend(s:parse_options(a:bang, 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)
" TODO: improve this
if len(a:opts) != 1 | return {} | endif
func! s:parse_options(bang, opts)
if len(a:opts) != 1
let opts = {}
elseif type(a:opts[0]) == type({})
let opts = a:opts[0]
elseif type(a:opts[0]) == type('')
let opts = {'rev': a:opts[0]}
endif
if type(a:opts[0]) == type({})
return a:opts[0]
else
return {'rev': a:opts[0]}
if a:bang
let opts = extend({'sync':'no'}, opts)
endif endif
return opts
endf endf
func! s:parse_name(arg) func! s:parse_name(arg)
@ -47,6 +52,7 @@ func! s:parse_name(arg)
elseif arg =~? '^\s*\(git@\|git://\)\S\+' elseif arg =~? '^\s*\(git@\|git://\)\S\+'
\ || arg =~? '(file|https\?)://' \ || arg =~? '(file|https\?)://'
\ || arg =~? '\.git\s*$' \ || arg =~? '\.git\s*$'
\ || isdirectory(expand(arg))
let uri = arg let uri = arg
let name = split( substitute(uri,'/\?\.git\s*$','','i') ,'\/')[-1] let name = split( substitute(uri,'/\?\.git\s*$','','i') ,'\/')[-1]
else else
@ -76,7 +82,20 @@ endf
let s:bundle = {} let s:bundle = {}
func! s:bundle.nosync()
return has_key(self, 'sync') && 'no' == self.sync
endf
func! s:bundle.installed()
return !empty(split(globpath(self.path(), '*'), "\n"))
endf
func! s:bundle.path() func! s:bundle.path()
" TODO: should lcd to tmpdir here
if self.nosync() && isdirectory(expand(self.uri))
return self.uri
endif
return join([g:vundle#bundle_dir, self.name], '/') return join([g:vundle#bundle_dir, self.name], '/')
endf endf


+ 4
- 5
autoload/vundle/installer.vim View File

@ -1,4 +1,5 @@
func! vundle#installer#install(bang, ...) abort func! vundle#installer#install(bang, ...) abort
if !isdirectory(g:vundle#bundle_dir) | call mkdir(g:vundle#bundle_dir, 'p') | endif
let bundles = (a:1 == '') ? let bundles = (a:1 == '') ?
\ 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, {})')
@ -87,12 +88,10 @@ func! s:helptags(rtp) abort
helptags `=a:rtp.'/doc/'` helptags `=a:rtp.'/doc/'`
endf endf
func! s:installed(bundle) abort
return !empty(split(globpath(a:bundle.path(), '*'), "\n"))
endf
func! vundle#installer#sync(bang, bundle) abort
if s:installed(a:bundle)
func! s:sync(bang, bundle) abort
if a:bundle.nosync() | return a:bang | endif
if a:bundle.installed()
if !(a:bang) | return 0 | endif if !(a:bang) | return 0 | endif
let cmd = 'cd '.shellescape(a:bundle.path()).' && git pull' let cmd = 'cd '.shellescape(a:bundle.path()).' && git pull'
else else


+ 3
- 0
test/plugin/test_plugin.vim View File

@ -0,0 +1,3 @@
func! g:vundle_test_plugin()
return 'ok'
endf

+ 49
- 5
test/vimrc View File

@ -1,6 +1,10 @@
" vim -u test/vimrc " vim -u test/vimrc
set nocompatible set nocompatible
syntax on
silent exec 'e '.expand('<sfile>')
filetype off filetype off
runtime macros/matchit.vim runtime macros/matchit.vim
set rtp+=~/.vim/vundle.git/ set rtp+=~/.vim/vundle.git/
@ -34,19 +38,59 @@ Bundle 'rstacruz/sparkup.git', {'rtp': 'vim/'}
" Camel case " Camel case
Bundle 'vim-scripts/RubySinatra' Bundle 'vim-scripts/RubySinatra'
" PostInstall " PostInstall
Bundle 'wincent/Command-T' Bundle 'wincent/Command-T'
" NOSYNC
" existing directory
Bundle! '~/.vim/vundle.git/test/'
" just create one
Bundle! 'a_plugin'
"
" just create one, and override name
Bundle! 'b_plugin', {'name': 'zzz'}
filetype plugin indent on " Automatically detect file types. filetype plugin indent on " Automatically detect file types.
set wildignore+=doc " should not break helptags set wildignore+=doc " should not break helptags
func! s:assert_bundles() abort
augroup vimrc
au WinEnter * call Test()
augroup END
func! Test() abort
if 'ok' != g:vundle_test_plugin()
throw 'ooops'
endif
call Assert_bundles()
call Assert_a_bundle()
call Assert_b_bundle()
endf
func! Assert(cond, msg)
if !(a:cond)
throw a:msg
endif
endf
func! Assert_bundles() abort
for b in g:vundle#bundles for b in g:vundle#bundles
if (!isdirectory(b.path().'/.git'))
throw b.name.' not installed'
endif
call Assert(b.nosync() || b.installed(), b.name.' not installed')
endfor endfor
endf endf
call s:assert_bundles()
func! Assert_a_bundle() abort
let b = filter(copy(g:vundle#bundles), 'v:val.name == "a_plugin"')[0]
let c = (b.path() == expand(g:vundle#bundle_dir.'/'.'a_plugin'))
call Assert(c, b.name.' isnt instaled')
endf
func! Assert_b_bundle() abort
let b = filter(copy(g:vundle#bundles), 'v:val.name == "zzz"')[0]
let c = (b.path() == expand(g:vundle#bundle_dir.'/'.'zzz'))
call Assert(c, b.name.' isnt instaled')
endf

Loading…
Cancel
Save