1
0
mirror of https://github.com/pcvolkmer/vim-fugistate.git synced 2025-07-02 11:52:54 +00:00

Show overall git dir status

This commit is contained in:
2022-01-10 15:15:58 +01:00
parent ed8a9ecda5
commit b47b8091da
3 changed files with 60 additions and 22 deletions

View File

@ -4,12 +4,11 @@
let s:filename_status = ''
function! fugistate#update()
let s:changed = 0
let s:new = 0
let s:unversioned = 0
if empty(@%)
let s:filename_status = ''
return
endif
function! fugistate#update()
if empty(g:fugistate_expand_filename)
let filename = expand(@%)
@ -17,30 +16,59 @@ function! fugistate#update()
let filename = expand(g:fugistate_expand_filename)
endif
let s:changed = 0
let s:new = 0
let s:unversioned = 0
let s:filename_status = filename
try
let gitstatus = FugitiveExecute('status', '-s')
if gitstatus.exit_status == 0
for filestate in gitstatus.stdout
if match(filestate, '^?') == 0
let s:unversioned = s:unversioned + 1
elseif match(filestate, '^A') == 0
let s:new = s:new + 1
elseif ! empty(filestate)
let s:changed = s:changed + 1
endif
if ! FugitiveIsGitDir()
let s:filename_status = filename
return
if ! empty(@%) && @% == filestate[3:]
let s:filename_status = filename . " [" . filestate[0:1] . "]"
endif
endfor
endif
let gitstatus = FugitiveExecute('status', '-s', @%)
if gitstatus.exit_status != 0 || empty(gitstatus.stdout[0])
let s:filename_status = filename
return
endif
let s:filename_status = filename . " [" . gitstatus.stdout[0][0:1] . "]"
catch
let s:filename_status = filename
endtry
endfunction
function! fugistate#filename_status()
function! fugistate#file()
return s:filename_status
endfunction
function! fugistate#gitdir()
let s:out = []
if s:changed == 1
call add(s:out, "1 change")
endif
if s:changed > 1
call add(s:out, s:changed . " changes")
endif
if s:new > 0
call add(s:out, s:new . " new")
endif
if s:unversioned > 0
call add(s:out, s:unversioned . " unversioned")
endif
return join(s:out, ', ')
endfunction