Merge pull request #2337 from vim-airline/Functionalization_of_branch_extension
[refactor] Functionalization of branch extension
This commit is contained in:
commit
cb1bc19064
|
@ -86,29 +86,36 @@ let s:sha1size = get(g:, 'airline#extensions#branch#sha1_len', 7)
|
|||
|
||||
function! s:update_git_branch()
|
||||
call airline#util#ignore_next_focusgain()
|
||||
if !airline#util#has_fugitive() && !airline#util#has_gina()
|
||||
if airline#util#has_fugitive()
|
||||
call s:config_fugitive_branch()
|
||||
elseif airline#util#has_gina()
|
||||
call s:config_gina_branch()
|
||||
else
|
||||
let s:vcs_config['git'].branch = ''
|
||||
return
|
||||
endif
|
||||
if airline#util#has_fugitive()
|
||||
let s:vcs_config['git'].branch = exists("*FugitiveHead") ?
|
||||
\ FugitiveHead(s:sha1size) : fugitive#head(s:sha1size)
|
||||
if s:vcs_config['git'].branch is# 'master' &&
|
||||
\ airline#util#winwidth() < 81
|
||||
" Shorten default a bit
|
||||
let s:vcs_config['git'].branch='mas'
|
||||
endif
|
||||
else
|
||||
try
|
||||
let g:gina#component#repo#commit_length = s:sha1size
|
||||
let s:vcs_config['git'].branch = gina#component#repo#branch()
|
||||
catch
|
||||
endtry
|
||||
if s:vcs_config['git'].branch is# 'master' &&
|
||||
\ airline#util#winwidth() < 81
|
||||
" Shorten default a bit
|
||||
let s:vcs_config['git'].branch='mas'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:config_fugitive_branch() abort
|
||||
let s:vcs_config['git'].branch = exists('*FugitiveHead') ?
|
||||
\ FugitiveHead(s:sha1size) : fugitive#head(s:sha1size)
|
||||
if s:vcs_config['git'].branch is# 'master' &&
|
||||
\ airline#util#winwidth() < 81
|
||||
" Shorten default a bit
|
||||
let s:vcs_config['git'].branch='mas'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:config_gina_branch() abort
|
||||
try
|
||||
let g:gina#component#repo#commit_length = s:sha1size
|
||||
let s:vcs_config['git'].branch = gina#component#repo#branch()
|
||||
catch
|
||||
endtry
|
||||
if s:vcs_config['git'].branch is# 'master' &&
|
||||
\ airline#util#winwidth() < 81
|
||||
" Shorten default a bit
|
||||
let s:vcs_config['git'].branch='mas'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
|
Loading…
Reference in New Issue