Browse Source

plugin subsystem && mercurial intergration added

pull/268/head
zdm 13 years ago
parent
commit
c70e0c371b
4 changed files with 145 additions and 93 deletions
  1. +21
    -19
      autoload/vundle/config.vim
  2. +53
    -49
      autoload/vundle/installer.vim
  3. +47
    -0
      autoload/vundle/plugin/hg.vim
  4. +24
    -25
      autoload/vundle/scripts.vim

+ 21
- 19
autoload/vundle/config.vim View File

@ -42,26 +42,28 @@ 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'
let arg = a:arg
let is_plugin = matchlist(arg, '^\(\w\+\)+\(.\+\)')
if !empty(is_plugin)
return call("vundle#plugin#" . is_plugin[1] . "#parse_name", [arg, is_plugin[1], is_plugin[2]])
else
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]
else
let name = arg
let uri = git_proto.'://github.com/vim-scripts/'.name.'.git'
endif
return {'name': name, 'uri': uri, 'name_spec': arg, 'plugin': '' }
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]
else
let name = arg
let uri = git_proto.'://github.com/vim-scripts/'.name.'.git'
endif
return {'name': name, 'uri': uri, 'name_spec': arg }
endf
func! s:rtp_rm_a()


+ 53
- 49
autoload/vundle/installer.vim View File

@ -114,12 +114,12 @@ func! vundle#installer#helptags(bundles) abort
let bundle_dirs = map(copy(a:bundles),'v:val.rtpath')
let help_dirs = filter(bundle_dirs, 's:has_doc(v:val)')
call s:log('')
call s:log('Helptags:')
call vundle#installer#log('')
call vundle#installer#log('Helptags:')
call map(copy(help_dirs), 's:helptags(v:val)')
call s:log('Helptags: '.len(help_dirs).' bundles processed')
call vundle#installer#log('Helptags: '.len(help_dirs).' bundles processed')
return help_dirs
endf
@ -172,12 +172,12 @@ func! vundle#installer#delete(bang, dir_name) abort
let bundle = vundle#config#init_bundle(a:dir_name, {})
let cmd .= ' '.shellescape(bundle.path())
let out = s:system(cmd)
let out = vundle#installer#system(cmd)
call s:log('')
call s:log('Bundle '.a:dir_name)
call s:log('$ '.cmd)
call s:log('> '.out)
call vundle#installer#log('')
call vundle#installer#log('Bundle '.a:dir_name)
call vundle#installer#log('$ '.cmd)
call vundle#installer#log('> '.out)
if 0 != v:shell_error
return 'error'
@ -196,52 +196,56 @@ endf
func! s:helptags(rtp) abort
let doc_path = a:rtp.'/doc/'
call s:log(':helptags '.doc_path)
call vundle#installer#log(':helptags '.doc_path)
try
execute 'helptags ' . doc_path
catch
call s:log("> Error running :helptags ".doc_path)
call vundle#installer#log("> Error running :helptags ".doc_path)
endtry
endf
func! s:sync(bang, bundle) abort
let git_dir = expand(a:bundle.path().'/.git/', 1)
if isdirectory(git_dir) || filereadable(expand(a:bundle.path().'/.git', 1))
if !(a:bang) | return 'todate' | endif
let cmd = 'cd '.shellescape(a:bundle.path()).' && git pull && git submodule update --init --recursive'
let cmd = g:shellesc_cd(cmd)
let get_current_sha = 'cd '.shellescape(a:bundle.path()).' && git rev-parse HEAD'
let get_current_sha = g:shellesc_cd(get_current_sha)
let initial_sha = s:system(get_current_sha)[0:15]
else
let cmd = 'git clone --recursive '.shellescape(a:bundle.uri).' '.shellescape(a:bundle.path())
let initial_sha = ''
endif
let out = s:system(cmd)
call s:log('')
call s:log('Bundle '.a:bundle.name_spec)
call s:log('$ '.cmd)
call s:log('> '.out)
if 0 != v:shell_error
return 'error'
end
if empty(initial_sha)
return 'new'
endif
let updated_sha = s:system(get_current_sha)[0:15]
if initial_sha == updated_sha
return 'todate'
endif
call add(g:updated_bundles, [initial_sha, updated_sha, a:bundle])
return 'updated'
if a:bundle.plugin != ''
return call("vundle#plugin#" . a:bundle.plugin . "#sync", [a:bang, a:bundle])
else
let git_dir = expand(a:bundle.path().'/.git/', 1)
if isdirectory(git_dir) || filereadable(expand(a:bundle.path().'/.git', 1))
if !(a:bang) | return 'todate' | endif
let cmd = 'cd '.shellescape(a:bundle.path()).' && git pull && git submodule update --init --recursive'
let cmd = g:shellesc_cd(cmd)
let get_current_sha = 'cd '.shellescape(a:bundle.path()).' && git rev-parse HEAD'
let get_current_sha = g:shellesc_cd(get_current_sha)
let initial_sha = vundle#installer#system(get_current_sha)[0:15]
else
let cmd = 'git clone --recursive '.shellescape(a:bundle.uri).' '.shellescape(a:bundle.path())
let initial_sha = ''
endif
let out = vundle#installer#system(cmd)
call vundle#installer#log('')
call vundle#installer#log('Bundle '.a:bundle.name_spec)
call vundle#installer#log('$ '.cmd)
call vundle#installer#log('> '.out)
if 0 != v:shell_error
return 'error'
end
if empty(initial_sha)
return 'new'
endif
let updated_sha = vundle#installer#system(get_current_sha)[0:15]
if initial_sha == updated_sha
return 'todate'
endif
call add(g:updated_bundles, [initial_sha, updated_sha, a:bundle])
return 'updated'
endif
endf
func! g:shellesc(cmd) abort
@ -263,11 +267,11 @@ func! g:shellesc_cd(cmd) abort
endif
endf
func! s:system(cmd) abort
func! vundle#installer#system(cmd) abort
return system(a:cmd)
endf
func! s:log(str) abort
func! vundle#installer#log(str) abort
let fmt = '%y%m%d %H:%M:%S'
call add(g:vundle_log, '['.strftime(fmt).'] '.a:str)
return a:str


+ 47
- 0
autoload/vundle/plugin/hg.vim View File

@ -0,0 +1,47 @@
func! vundle#plugin#hg#parse_name(name_spec, plugin, uri)
return {'name': matchstr(a:uri, '[a-z0-9-]\+$'), 'uri': a:uri, 'name_spec': a:name_spec, 'plugin': a:plugin }
endf
func! vundle#plugin#hg#sync(bang, bundle)
let hg_dir = expand(a:bundle.path().'/.hg/', 1)
if isdirectory(hg_dir) || filereadable(expand(a:bundle.path().'/.hg', 1))
if !(a:bang) | return 'todate' | endif
let cmd = 'cd '.shellescape(a:bundle.path()).' && hg pull && hg up -C'
let cmd = g:shellesc_cd(cmd)
let get_current_sha = 'cd '.shellescape(a:bundle.path()).' && hg identify -i'
let get_current_sha = g:shellesc_cd(get_current_sha)
let initial_sha = vundle#installer#system(get_current_sha)[0:15]
else
let cmd = 'hg clone '.shellescape(a:bundle.uri).' '.shellescape(a:bundle.path())
let initial_sha = ''
endif
let out = vundle#installer#system(cmd)
call vundle#installer#log('')
call vundle#installer#log('Bundle '.a:bundle.name_spec)
call vundle#installer#log('$ '.cmd)
call vundle#installer#log('> '.out)
if 0 != v:shell_error
return 'error'
end
if empty(initial_sha)
return 'new'
endif
let updated_sha = vundle#installer#system(get_current_sha)[0:15]
if initial_sha == updated_sha
return 'todate'
endif
call add(g:updated_bundles, [initial_sha, updated_sha, a:bundle])
return 'updated'
endf
func! vundle#plugin#hg#create_changelog(bundle, initial_sha, updated_sha)
return 'Update log not accessible!'
endf

+ 24
- 25
autoload/vundle/scripts.vim View File

@ -34,31 +34,30 @@ func! s:view_log()
endf
func! s:create_changelog() abort
for bundle_data in g:updated_bundles
let initial_sha = bundle_data[0]
let updated_sha = bundle_data[1]
let bundle = bundle_data[2]
let cmd = 'cd '.shellescape(bundle.path()).
\ ' && git log --pretty=format:"%s %an, %ar" --graph '.
\ initial_sha.'..'.updated_sha
let cmd = g:shellesc_cd(cmd)
let updates = system(cmd)
call add(g:vundle_changelog, '')
call add(g:vundle_changelog, 'Updated Bundle: '.bundle.name)
if bundle.uri =~ "https://github.com"
call add(g:vundle_changelog, 'Compare at: '.bundle.uri[0:-5].'/compare/'.initial_sha.'...'.updated_sha)
endif
for update in split(updates, '\n')
let update = substitute(update, '\s\+$', '', '')
call add(g:vundle_changelog, ' '.update)
endfor
endfor
for bundle_data in g:updated_bundles
let initial_sha = bundle_data[0]
let updated_sha = bundle_data[1]
let bundle = bundle_data[2]
call add(g:vundle_changelog, '')
call add(g:vundle_changelog, 'Updated Bundle: '.bundle.name)
if bundle.plugin != ''
let updates = call("vundle#plugin#" . bundle.plugin . "#create_changelog", [bundle, initial_sha, updated_sha])
else
let cmd = 'cd ' . shellescape(bundle.path()) . ' && git log --pretty=format:"%s %an, %ar" --graph ' . initial_sha . '..' . updated_sha
let cmd = g:shellesc_cd(cmd)
let updates = system(cmd)
if bundle.uri =~ "https://github.com"
call add(g:vundle_changelog, 'Compare at: '.bundle.uri[0:-5].'/compare/'.initial_sha.'...'.updated_sha)
endif
endif
for update in split(updates, '\n')
let update = substitute(update, '\s\+$', '', '')
call add(g:vundle_changelog, ' '.update)
endfor
endfor
endf
func! s:view_changelog()


Loading…
Cancel
Save