Fix #28: False alarm from PlugStatus when tag used
This commit is contained in:
parent
ee04a646d3
commit
8863a3a53c
2 changed files with 13 additions and 4 deletions
15
plug.vim
15
plug.vim
|
@ -691,6 +691,11 @@ function! s:system(cmd)
|
||||||
return system(s:is_win ? '('.a:cmd.')' : a:cmd)
|
return system(s:is_win ? '('.a:cmd.')' : a:cmd)
|
||||||
endfunction
|
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)
|
function! s:git_valid(spec, check_branch, cd)
|
||||||
let ret = 1
|
let ret = 1
|
||||||
let msg = 'OK'
|
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
|
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 result = split(s:system("git rev-parse --abbrev-ref HEAD 2>&1 && git config remote.origin.url"), '\n')
|
||||||
let remote = result[-1]
|
let remote = result[-1]
|
||||||
if v:shell_error != 0
|
if v:shell_error
|
||||||
let msg = join([remote, "PlugClean required."], "\n")
|
let msg = join([remote, "PlugClean required."], "\n")
|
||||||
let ret = 0
|
let ret = 0
|
||||||
elseif !s:compare_git_uri(remote, a:spec.uri)
|
elseif !s:compare_git_uri(remote, a:spec.uri)
|
||||||
|
@ -708,8 +713,12 @@ 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]
|
||||||
if a:spec.branch != branch
|
let tag = a:spec.branch == 'master' ? '' :
|
||||||
let msg = 'Invalid branch: '.branch.'. Try PlugUpdate.'
|
\ 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
|
let ret = 0
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -134,7 +134,7 @@ Execute (PlugStatus):
|
||||||
g/^$/d
|
g/^$/d
|
||||||
|
|
||||||
Expect:
|
Expect:
|
||||||
Invalid branch: no-t_co. Try PlugUpdate.
|
Invalid branch/tag: no-t_co. Try PlugUpdate.
|
||||||
- vim-emoji: OK
|
- vim-emoji: OK
|
||||||
Finished. 1 error(s).
|
Finished. 1 error(s).
|
||||||
[==]
|
[==]
|
||||||
|
|
Loading…
Reference in a new issue