Improve PlugStatus message

Invalid branch/tag: %s (expected: %s). Try PlugUpdate.
This commit is contained in:
Junegunn Choi 2014-06-23 12:22:25 +09:00
parent afe7dc6f8f
commit cc37ed48be
2 changed files with 62 additions and 32 deletions

View file

@ -713,13 +713,13 @@ function! s:git_valid(spec, check_branch, cd)
let ret = 0 let ret = 0
elseif a:check_branch elseif a:check_branch
let branch = result[0] let branch = result[0]
let tag = a:spec.branch ==# 'master' ? '' : if a:spec.branch !=# branch
\ s:system_chomp('git describe --exact-match --tags HEAD 2>&1') let tag = s:system_chomp('git describe --exact-match --tags HEAD 2>&1')
if a:spec.branch != branch && a:spec.branch != tag if a:spec.branch !=# tag
let msg = 'Invalid branch/tag: ' . let msg = printf('Invalid branch/tag: %s (expected: %s). Try PlugUpdate.',
\ ((empty(tag) || tag ==# 'HEAD') ? branch : tag) . \ (empty(tag) ? branch : tag), a:spec.branch)
\ '. Try PlugUpdate.' let ret = 0
let ret = 0 endif
endif endif
endif endif
if a:cd | cd - | endif if a:cd | cd - | endif

View file

@ -15,6 +15,15 @@ Execute (Initialize test environment):
colo default colo default
pclose pclose
function! PlugStatusSorted()
PlugStatus
%y
q
normal! P
%sort
g/^$/d
endfunction
let g:vimrc_reloaded = 0 let g:vimrc_reloaded = 0
let vimrc = tempname() let vimrc = tempname()
call writefile(['let g:vimrc_reloaded += 1'], vimrc) call writefile(['let g:vimrc_reloaded += 1'], vimrc)
@ -64,6 +73,12 @@ Execute (Test Plug command):
AssertEqual join([temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir AssertEqual join([temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
AssertEqual 'no-t_co', g:plugs['seoul256.vim'].branch AssertEqual 'no-t_co', g:plugs['seoul256.vim'].branch
" Git repo with tag
Plug 'junegunn/goyo.vim', '1.5.3'
AssertEqual 'https://git:@github.com/junegunn/goyo.vim.git', g:plugs['goyo.vim'].uri
AssertEqual join([temp_plugged, 'goyo.vim/'], '/'), g:plugs['goyo.vim'].dir
AssertEqual '1.5.3', g:plugs['goyo.vim'].branch
" Git URI " Git URI
Plug 'git@github.com:junegunn/vim-emoji.git' Plug 'git@github.com:junegunn/vim-emoji.git'
AssertEqual 'git@github.com:junegunn/vim-emoji.git', g:plugs['vim-emoji'].uri AssertEqual 'git@github.com:junegunn/vim-emoji.git', g:plugs['vim-emoji'].uri
@ -75,18 +90,20 @@ Execute (Test Plug command):
AssertEqual 'https://git:@github.com/vim-scripts/beauty256.git', g:plugs.beauty256.uri AssertEqual 'https://git:@github.com/vim-scripts/beauty256.git', g:plugs.beauty256.uri
AssertEqual 'master', g:plugs.beauty256.branch AssertEqual 'master', g:plugs.beauty256.branch
AssertEqual 3, len(g:plugs) AssertEqual 4, len(g:plugs)
Execute (Plug command with dictionary option): Execute (Plug command with dictionary option):
Log string(g:plugs)
Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co', 'rtp': '././' } Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co', 'rtp': '././' }
AssertEqual join([temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir AssertEqual join([temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
AssertEqual '././', g:plugs['seoul256.vim'].rtp AssertEqual '././', g:plugs['seoul256.vim'].rtp
AssertEqual 3, len(g:plugs) Log string(g:plugs)
AssertEqual 4, len(g:plugs)
Execute (PlugStatus before installation): Execute (PlugStatus before installation):
PlugStatus PlugStatus
AssertEqual 3, len(filter(getline(1, line('$')), 'v:val =~ "Not found"')) AssertEqual 4, len(filter(getline(1, line('$')), 'v:val =~ "Not found"'))
q q
Execute (PlugClean before installation): Execute (PlugClean before installation):
@ -116,9 +133,33 @@ Execute (PlugClean after installation):
Execute (PlugStatus after installation): Execute (PlugStatus after installation):
PlugStatus PlugStatus
AssertEqual 3, len(filter(getline(1, line('$')), 'v:val =~ "OK"')) AssertEqual 4, len(filter(getline(1, line('$')), 'v:val =~ "OK"'))
q q
Execute (Change tag of goyo.vim):
call plug#begin()
Plug 'junegunn/goyo.vim'
call plug#end()
Execute (PlugStatus):
call PlugStatusSorted()
Expect:
Invalid branch/tag: 1.5.3 (expected: master). Try PlugUpdate.
Finished. 1 error(s).
[=]
x goyo.vim:
Execute (PlugUpdate to set the right branch):
PlugUpdate
call PlugStatusSorted()
AssertEqual 2, g:vimrc_reloaded
Expect:
- goyo.vim: OK
Finished. 0 error(s).
[=]
Execute (Change branch of seoul256.vim): Execute (Change branch of seoul256.vim):
call plug#begin() call plug#begin()
Plug 'junegunn/seoul256.vim' Plug 'junegunn/seoul256.vim'
@ -126,15 +167,10 @@ Execute (Change branch of seoul256.vim):
call plug#end() call plug#end()
Execute (PlugStatus): Execute (PlugStatus):
PlugStatus call PlugStatusSorted()
%y
q
normal! P
%sort
g/^$/d
Expect: Expect:
Invalid branch/tag: no-t_co. Try PlugUpdate. Invalid branch/tag: no-t_co (expected: master). Try PlugUpdate.
- vim-emoji: OK - vim-emoji: OK
Finished. 1 error(s). Finished. 1 error(s).
[==] [==]
@ -147,12 +183,7 @@ Execute (Change URI of seoul256.vim):
call plug#end() call plug#end()
Execute (PlugStatus): Execute (PlugStatus):
PlugStatus call PlugStatusSorted()
%y
q
normal! P
%sort
g/^$/d
Expect: Expect:
Expected: https://git:@github.com/junegunn.choi/seoul256.vim.git Expected: https://git:@github.com/junegunn.choi/seoul256.vim.git
@ -172,6 +203,8 @@ Expect:
Execute (PlugClean! to remove seoul256.vim): Execute (PlugClean! to remove seoul256.vim):
PlugClean! PlugClean!
" Three removed, emoji left
AssertEqual 3, len(filter(getline(1, line('$')), 'v:val =~ "^- "'))
AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "Removed"')) AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "Removed"'))
Assert empty(globpath(&rtp, 'colors/seoul256.vim')) Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
Assert !empty(globpath(&rtp, 'autoload/emoji.vim')) Assert !empty(globpath(&rtp, 'autoload/emoji.vim'))
@ -184,12 +217,7 @@ Execute (Change GIT URI of vim-emoji):
call plug#end() call plug#end()
Execute (PlugStatus): Execute (PlugStatus):
PlugStatus call PlugStatusSorted()
%y
q
normal! P
%sort
g/^$/d
Expect: Expect:
Expected: https://git:@github.com/junegunn/vim-emoji.git Expected: https://git:@github.com/junegunn/vim-emoji.git
@ -203,6 +231,7 @@ Expect:
Execute (PlugClean! to remove vim-emoji): Execute (PlugClean! to remove vim-emoji):
PlugClean! PlugClean!
AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "^- "'))
AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "Removed"')) AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "Removed"'))
Assert empty(globpath(&rtp, 'colors/seoul256.vim')) Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
Assert empty(globpath(&rtp, 'autoload/emoji.vim')) Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
@ -211,7 +240,7 @@ Execute (PlugClean! to remove vim-emoji):
Execute (PlugUpdate to install both again): Execute (PlugUpdate to install both again):
PlugUpdate PlugUpdate
AssertEqual 2, len(filter(getline(1, line('$')), 'v:val =~ "Cloning into"')) AssertEqual 2, len(filter(getline(1, line('$')), 'v:val =~ "Cloning into"'))
AssertEqual 2, g:vimrc_reloaded AssertEqual 3, g:vimrc_reloaded
Assert !empty(globpath(&rtp, 'colors/seoul256.vim')), 'seoul256.vim should be found' Assert !empty(globpath(&rtp, 'colors/seoul256.vim')), 'seoul256.vim should be found'
Assert !empty(globpath(&rtp, 'autoload/emoji.vim')), 'vim-emoji should be found' Assert !empty(globpath(&rtp, 'autoload/emoji.vim')), 'vim-emoji should be found'
q q
@ -219,7 +248,7 @@ Execute (PlugUpdate to install both again):
Execute (PlugUpdate only to find out plugins are up-to-date, D key to check): Execute (PlugUpdate only to find out plugins are up-to-date, D key to check):
PlugUpdate PlugUpdate
AssertEqual 2, len(filter(getline(1, line('$')), 'v:val =~ "Already up-to-date"')) AssertEqual 2, len(filter(getline(1, line('$')), 'v:val =~ "Already up-to-date"'))
AssertEqual 3, g:vimrc_reloaded AssertEqual 4, g:vimrc_reloaded
normal D normal D
AssertEqual 'No updates.', getline(1) AssertEqual 'No updates.', getline(1)
q q
@ -362,6 +391,7 @@ Execute (Cleanup):
unlet g:plug_home unlet g:plug_home
unlet g:vimrc_reloaded unlet g:vimrc_reloaded
unlet temp_plugged vader plug basertp save_rtp repo lnum unlet temp_plugged vader plug basertp save_rtp repo lnum
delf PlugStatusSorted
Restore Restore
source $MYVIMRC source $MYVIMRC