Browse Source

Merge ac9400fa76 into 57895c0cd4

pull/134/merge
GitHub Merge Button 14 years ago
parent
commit
aee2883750
2 changed files with 84 additions and 26 deletions
  1. +39
    -17
      autoload/vundle/config.vim
  2. +45
    -9
      autoload/vundle/installer.vim

+ 39
- 17
autoload/vundle/config.vim View File

@ -42,27 +42,49 @@ func! s:parse_options(opts)
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'
if arg =~? '^\s*\(gh\|github\):\S\+'
\ || arg =~? '^[a-z0-9][a-z0-9-]*/[^/]\+$'
let uri = git_proto.'://github.com/'.split(arg, ':')[-1]
if uri !~? '\.git$'
let uri .= '.git'
endif
let name = substitute(split(uri,'\/')[-1], '\.git\s*$','','i')
elseif arg =~? '^\s*\(git@\|git://\)\S\+'
\ || arg =~? '\(file\|https\?\)://'
\ || arg =~? '\.git\s*$'
let uri = arg
let name = split( substitute(uri,'/\?\.git\s*$','','i') ,'\/')[-1]
" default to git
let type = 'git'
" mercurial
if a:arg[:3] ==# 'bit:'
" bit:{N}/{repo} {"type": "hg", "uri": "http://bitbucket.org/{Name}/{repo}}
let uri = 'https://bitbucket.org/'.a:arg[len('bit:'):]
let name = split(uri,'\/')[-1]
let type = 'hg'
elseif a:arg[:2]==#'hg:'
" hg:{uri} {"type": "hg", "uri": {uri}}
let uri = a:arg[len('hg:'):]
let name = split(uri,'\/')[-1]
let type = 'hg'
" bazaar
elseif a:arg[:2]==#'lp:'
let uri = a:arg
let name = split (uri, ':')[-1]
let type = 'bzr'
" git
elseif a:arg =~? '^\s*\(gh\|github\):\S\+'
\ || a:arg =~? '^[a-z0-9][a-z0-9-]*/[^/]\+$'
" github|gh:{N}/{Repo} {"type": "git", "uri": "git://github.com/{N}/{Repo}"}
let uri = git_proto.'://github.com/'.split(a:arg, ':')[-1]
if uri !~? '\.git$'
let uri .= '.git'
endif
let name = substitute(split(uri,'\/')[-1], '\.git\s*$','','i')
elseif a:arg =~? '^\s*\(git@\|git://\)\S\+'
\ || a:arg =~? '\(file\|https\?\)://'
\ || a:arg =~? '\.git\s*$'
" git|https:{uri} {"type": "git", "uri": {uri}}
let uri = a:arg
let name = split( substitute(uri,'/\?\.git\s*$','','i') ,'\/')[-1]
else
let name = arg
let uri = git_proto.'://github.com/vim-scripts/'.name.'.git'
let name = a:arg
let uri = git_proto.'://github.com/vim-scripts/'.name.'.git'
endif
return {'name': name, 'uri': uri, 'name_spec': arg }
endf
return {'name': name, 'uri': uri, 'name_spec': a:arg, 'type':type }
endf
func! s:rtp_rm_a()
let paths = map(copy(g:bundles), 'v:val.rtpath')


+ 45
- 9
autoload/vundle/installer.vim View File

@ -203,17 +203,49 @@ func! s:helptags(rtp) abort
endf
func! s:sync(bang, bundle) abort
let git_dir = expand(a:bundle.path().'/.git/', 1)
if isdirectory(git_dir)
if !(a:bang) | return 'todate' | 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
let types = {'.git' : 'git', '.hg' : 'hg', '.bzr' : 'bzr', '.svn': 'svn' }
" not sure if necessary, will detect DVCS type from directory
if empty(a:bundle.type)
for [k,t] in items(types)
let repo_dir = expand(a:bundle.path().'/.'.k.'/')
if isdirectory(repo_dir) | let type = t | break | endif
endfor
else
let type = a:bundle.type
let repo_dir = expand(a:bundle.path().'/.'.a:bundle.type.'/')
endif
let dir = shellescape(a:bundle.path())
let vcs_update = {
\'git': 'cd '.dir.' && git pull',
\'hg': 'hg pull -u -R '.dir,
\'bzr': 'bzr pull -d '.dir,
\'svn': 'cd '.dir.' && svn update'}
let vcs_checkout = {
\'git': 'git clone '.a:bundle.uri.' '.dir.'',
\'hg': 'hg clone '.a:bundle.uri.' '.dir.'',
\'bzr': 'bzr branch '.a:bundle.uri.' '.dir.'',
\'svn': ''}
if type =~ '^\%(git\|hg\|bzr\|svn\)$'
" if folder already exists, just pull
if isdirectory(repo_dir)
if !(a:bang) | return 'todate' | endif
let cmd = vcs_update[type]
else
let cmd = vcs_checkout[type]
endif
else
let cmd = 'git clone '.a:bundle.uri.' '.shellescape(a:bundle.path())
" how did we get here?
return
endif
if s:iswindows()
let cmd = substitute(cmd, '^cd ','cd /d ','') " add /d switch to change drives
let cmd = '"'.cmd.'"' " enclose in quotes
endif
let out = s:system(cmd)
@ -256,3 +288,7 @@ func! s:log(str) abort
call add(g:vundle_log, '['.strftime(fmt).'] '.a:str)
return a:str
endf
func! s:iswindows() abort
return has("win16") || has("win32") || has("win64")
endf

Loading…
Cancel
Save