Merge pull request #2337 from vim-airline/Functionalization_of_branch_extension

[refactor] Functionalization of branch extension
This commit is contained in:
Christian Brabandt 2021-02-15 16:12:20 +01:00 committed by GitHub
commit cb1bc19064
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 20 deletions

View File

@ -86,19 +86,27 @@ let s:sha1size = get(g:, 'airline#extensions#branch#sha1_len', 7)
function! s:update_git_branch() function! s:update_git_branch()
call airline#util#ignore_next_focusgain() 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 = '' let s:vcs_config['git'].branch = ''
return return
endif endif
if airline#util#has_fugitive() endfunction
let s:vcs_config['git'].branch = exists("*FugitiveHead") ?
function! s:config_fugitive_branch() abort
let s:vcs_config['git'].branch = exists('*FugitiveHead') ?
\ FugitiveHead(s:sha1size) : fugitive#head(s:sha1size) \ FugitiveHead(s:sha1size) : fugitive#head(s:sha1size)
if s:vcs_config['git'].branch is# 'master' && if s:vcs_config['git'].branch is# 'master' &&
\ airline#util#winwidth() < 81 \ airline#util#winwidth() < 81
" Shorten default a bit " Shorten default a bit
let s:vcs_config['git'].branch='mas' let s:vcs_config['git'].branch='mas'
endif endif
else endfunction
function! s:config_gina_branch() abort
try try
let g:gina#component#repo#commit_length = s:sha1size let g:gina#component#repo#commit_length = s:sha1size
let s:vcs_config['git'].branch = gina#component#repo#branch() let s:vcs_config['git'].branch = gina#component#repo#branch()
@ -109,7 +117,6 @@ function! s:update_git_branch()
" Shorten default a bit " Shorten default a bit
let s:vcs_config['git'].branch='mas' let s:vcs_config['git'].branch='mas'
endif endif
endif
endfunction endfunction
function! s:display_git_branch() function! s:display_git_branch()