Add missing function

This commit is contained in:
Yasuhiro Matsumoto 2020-08-27 21:59:09 +09:00 committed by Junegunn Choi
parent 4a3c5e7ac2
commit 5706f70f8f

View File

@ -2211,6 +2211,14 @@ function! s:system_chomp(...)
return v:shell_error ? '' : substitute(ret, '\n$', '', '') return v:shell_error ? '' : substitute(ret, '\n$', '', '')
endfunction endfunction
function! s:git_get_branch(dir)
let result = s:lines(s:system('git symbolic-ref --short HEAD', a:dir))
if v:shell_error
return ''
endif
return result[-1]
endfunction
function! s:git_validate(spec, check_branch) function! s:git_validate(spec, check_branch)
let err = '' let err = ''
if isdirectory(a:spec.dir) if isdirectory(a:spec.dir)
@ -2234,6 +2242,9 @@ function! s:git_validate(spec, check_branch)
endif endif
elseif a:check_branch elseif a:check_branch
let branch = result[0] let branch = result[0]
if empty(branch)
let branch = 'HEAD'
endif
" Check tag " Check tag
if has_key(a:spec, 'tag') if has_key(a:spec, 'tag')
let tag = s:system_chomp('git describe --exact-match --tags HEAD 2>&1', a:spec.dir) let tag = s:system_chomp('git describe --exact-match --tags HEAD 2>&1', a:spec.dir)
@ -2242,7 +2253,7 @@ function! s:git_validate(spec, check_branch)
\ (empty(tag) ? 'N/A' : tag), a:spec.tag) \ (empty(tag) ? 'N/A' : tag), a:spec.tag)
endif endif
" Check branch " Check branch
elseif a:spec.branch !=# branch elseif a:spec.branch != '' && a:spec.branch !=# branch
let err = printf('Invalid branch: %s (expected: %s). Try PlugUpdate.', let err = printf('Invalid branch: %s (expected: %s). Try PlugUpdate.',
\ branch, a:spec.branch) \ branch, a:spec.branch)
endif endif