Fix #28: False alarm from PlugStatus when tag used

This commit is contained in:
Junegunn Choi 2014-06-23 04:02:49 +09:00
parent ee04a646d3
commit 8863a3a53c
2 changed files with 13 additions and 4 deletions

View file

@ -691,6 +691,11 @@ function! s:system(cmd)
return system(s:is_win ? '('.a:cmd.')' : a:cmd)
endfunction
function! s:system_chomp(str)
let ret = s:system(a:str)
return v:shell_error ? '' : substitute(ret, '\n$', '', '')
endfunction
function! s:git_valid(spec, check_branch, cd)
let ret = 1
let msg = 'OK'
@ -698,7 +703,7 @@ function! s:git_valid(spec, check_branch, cd)
if a:cd | execute "cd " . s:esc(a:spec.dir) | endif
let result = split(s:system("git rev-parse --abbrev-ref HEAD 2>&1 && git config remote.origin.url"), '\n')
let remote = result[-1]
if v:shell_error != 0
if v:shell_error
let msg = join([remote, "PlugClean required."], "\n")
let ret = 0
elseif !s:compare_git_uri(remote, a:spec.uri)
@ -708,8 +713,12 @@ function! s:git_valid(spec, check_branch, cd)
let ret = 0
elseif a:check_branch
let branch = result[0]
if a:spec.branch != branch
let msg = 'Invalid branch: '.branch.'. Try PlugUpdate.'
let tag = a:spec.branch == 'master' ? '' :
\ s:system_chomp('git describe --exact-match --tags HEAD 2>&1')
if a:spec.branch != branch && a:spec.branch != tag
let msg = 'Invalid branch/tag: ' .
\ ((empty(tag) || tag ==# 'HEAD') ? branch : tag) .
\ '. Try PlugUpdate.'
let ret = 0
endif
endif

View file

@ -134,7 +134,7 @@ Execute (PlugStatus):
g/^$/d
Expect:
Invalid branch: no-t_co. Try PlugUpdate.
Invalid branch/tag: no-t_co. Try PlugUpdate.
- vim-emoji: OK
Finished. 1 error(s).
[==]