Merge remote-tracking branch 'root_branch/master' into respect_git_managed_tags

This commit is contained in:
h-east 2019-01-30 13:45:17 +09:00
commit 2383d89d7b
4 changed files with 81 additions and 6 deletions

View File

@ -193,6 +193,14 @@ function! s:ask_no_interrupt(...)
endtry
endfunction
function! s:lazy(plug, opt)
return has_key(a:plug, a:opt) &&
\ (empty(s:to_a(a:plug[a:opt])) ||
\ !isdirectory(a:plug.dir) ||
\ len(s:glob(s:rtp(a:plug), 'plugin')) ||
\ len(s:glob(s:rtp(a:plug), 'after/plugin')))
endfunction
function! plug#end()
if !exists('g:plugs')
return s:err('Call plug#begin() first')
@ -214,7 +222,7 @@ function! plug#end()
continue
endif
let plug = g:plugs[name]
if get(s:loaded, name, 0) || !has_key(plug, 'on') && !has_key(plug, 'for')
if get(s:loaded, name, 0) || !s:lazy(plug, 'on') && !s:lazy(plug, 'for')
let s:loaded[name] = 1
continue
endif
@ -774,6 +782,9 @@ function! s:prepare(...)
execute 'silent! unmap <buffer>' k
endfor
setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline modifiable nospell
if exists('+colorcolumn')
setlocal colorcolumn=
endif
setf vim-plug
if exists('g:syntax_on')
call s:syntax()
@ -1019,6 +1030,8 @@ function! s:update_impl(pull, force, args) abort
let s:clone_opt .= ' -c core.eol=lf -c core.autocrlf=input'
endif
let s:submodule_opt = s:git_version_requirement(2, 8) ? ' --jobs='.threads : ''
" Python version requirement (>= 2.7)
if python && !has('python3') && !ruby && !use_job && s:update.threads > 1
redir => pyv
@ -1110,7 +1123,7 @@ function! s:update_finish()
if !v:shell_error && filereadable(spec.dir.'/.gitmodules') &&
\ (s:update.force || has_key(s:update.new, name) || s:is_updated(spec.dir))
call s:log4(name, 'Updating submodules. This may take a while.')
let out .= s:bang('git submodule update --init --recursive 2>&1', spec.dir)
let out .= s:bang('git submodule update --init --recursive'.s:submodule_opt.' 2>&1', spec.dir)
endif
let msg = s:format_message(v:shell_error ? 'x': '-', name, out)
if v:shell_error
@ -1329,7 +1342,7 @@ while 1 " Without TCO, Vim stack is bound to explode
let name = keys(s:update.todo)[0]
let spec = remove(s:update.todo, name)
let new = !isdirectory(spec.dir)
let new = empty(globpath(spec.dir, '.git', 1))
call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...')
redraw
@ -2435,7 +2448,11 @@ function! s:diff()
call s:append_ul(2, origin ? 'Pending updates:' : 'Last update:')
for [k, v] in plugs
let range = origin ? '..origin/'.v.branch : 'HEAD@{1}..'
let diff = s:system_chomp('git log --graph --color=never '.join(map(['--pretty=format:%x01%h%x01%d%x01%s%x01%cr', range], 's:shellesc(v:val)')), v.dir)
let cmd = 'git log --graph --color=never '.join(map(['--pretty=format:%x01%h%x01%d%x01%s%x01%cr', range], 's:shellesc(v:val)'))
if has_key(v, 'rtp')
let cmd .= ' -- '.s:shellesc(v.rtp)
endif
let diff = s:system_chomp(cmd, v.dir)
if !empty(diff)
let ref = has_key(v, 'tag') ? (' (tag: '.v.tag.')') : has_key(v, 'commit') ? (' '.v.commit) : ''
call append(5, extend(['', '- '.k.':'.ref], map(s:lines(diff), 's:format_git_log(v:val)')))

View File

@ -41,6 +41,7 @@ Execute (#130 Proper cleanup of on-demand loading triggers):
Plug 'junegunn/vim-emoji', { 'on': ['EmojiCommand', 'EmojiCommand2', '<Plug>(EmojiMapping)'] }
call plug#end()
PlugInstall | q
call mkdir(g:plugs['vim-emoji'].dir.'/after/plugin', 'p')
Assert exists(':EmojiCommand'), 'EmojiCommand not defined'
Assert exists(':EmojiCommand2'), 'EmojiCommand2 not defined'

View File

@ -87,7 +87,7 @@ DOC
make_dirs z2/ z2
rm -rf "$PLUG_FIXTURES/ftplugin-msg"
mkdir -p "$PLUG_FIXTURES/ftplugin-msg/ftplugin"
mkdir -p "$PLUG_FIXTURES"/ftplugin-msg/{plugin,ftplugin}
echo "echomsg 'ftplugin-c'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/c.vim"
echo "echomsg 'ftplugin-java'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/java.vim"

View File

@ -537,6 +537,51 @@ Execute (PlugDiff):
Assert !empty(mapcheck("\<cr>"))
q
Execute (Do not show diff for commits outside of rtp):
call plug#begin()
call plug#end()
PlugClean!
call plug#begin()
Plug 'file://'.expand('$PLUG_FIXTURES').'/xxx'
Plug 'file://'.expand('$PLUG_FIXTURES').'/yyy', { 'rtp': 'rtp' }
call plug#end()
PlugInstall
Log getline(1, '$')
call system('cd "$PLUG_FIXTURES/xxx" && git commit --allow-empty -m update-xxx && git tag -f xxx')
call system('cd "$PLUG_FIXTURES/yyy" && git commit --allow-empty -m update-yyy && git tag -f yyy')
let g:plugs.yyy.tag = 'yyy'
PlugUpdate
Log getline(1, '$')
PlugDiff
" 1 plugin(s) updated.
" [==]
"
" Last update:
" ------------
"
" - xxx:
" * 7faa9b2 update-xxx (0 seconds ago)
"
" Pending updates:
" ----------------
"
" N/A
"
Log getline(1, '$')
AssertEqual 14, line('$')
AssertEqual '1 plugin(s) updated.', getline(1)
AssertEqual '[==]', getline(2)
AssertEqual 'Last update:', getline(4)
AssertEqual '- xxx:', getline(7)
Assert !empty(mapcheck('o'))
Assert !empty(mapcheck('X'))
Assert !empty(mapcheck("\<cr>"))
q
**********************************************************************
~ On-demand loading / Partial installation/update ~
**********************************************************************
@ -1511,7 +1556,7 @@ Execute (Commit hash support):
Log getline(1, '$')
AssertEqual 'x goyo.vim:', getline(5)
AssertEqual ' fatal: invalid reference: ffffffff', getline(6)
AssertEqual 0, stridx(getline(7), '- vim-emoji: HEAD is now at 9db7fcf...')
AssertEqual 0, stridx(getline(7), '- vim-emoji: HEAD is now at 9db7fcf')
let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
AssertEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
@ -1638,3 +1683,15 @@ Execute (#532 - Reuse plug window):
AssertEqual 2, winnr(), 'Current window is #2 after PlugStatus (but is '.winnr().')'
AssertEqual 2, winnr('$'), 'Three windows after PlugStatus (but got '.winnr('$').')'
q
Execute (#766 - Allow cloning into an empty directory):
let d = '/tmp/vim-plug-test/goyo-already'
call system('rm -rf ' . d)
call mkdir(d)
call plug#begin()
Plug 'junegunn/goyo.vim', { 'dir': d }
call plug#end()
PlugInstall
AssertExpect! '[=]', 1
q
unlet d