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,29 +86,36 @@ 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") ?
\ FugitiveHead(s:sha1size) : fugitive#head(s:sha1size) function! s:config_fugitive_branch() abort
if s:vcs_config['git'].branch is# 'master' && let s:vcs_config['git'].branch = exists('*FugitiveHead') ?
\ airline#util#winwidth() < 81 \ FugitiveHead(s:sha1size) : fugitive#head(s:sha1size)
" Shorten default a bit if s:vcs_config['git'].branch is# 'master' &&
let s:vcs_config['git'].branch='mas' \ airline#util#winwidth() < 81
endif " Shorten default a bit
else let s:vcs_config['git'].branch='mas'
try endif
let g:gina#component#repo#commit_length = s:sha1size endfunction
let s:vcs_config['git'].branch = gina#component#repo#branch()
catch function! s:config_gina_branch() abort
endtry try
if s:vcs_config['git'].branch is# 'master' && let g:gina#component#repo#commit_length = s:sha1size
\ airline#util#winwidth() < 81 let s:vcs_config['git'].branch = gina#component#repo#branch()
" Shorten default a bit catch
let s:vcs_config['git'].branch='mas' endtry
endif if s:vcs_config['git'].branch is# 'master' &&
\ airline#util#winwidth() < 81
" Shorten default a bit
let s:vcs_config['git'].branch='mas'
endif endif
endfunction endfunction