1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 12:50:04 +08:00

fix(git): avoid repeated push

This commit is contained in:
wsdjeg 2023-04-22 23:14:54 +08:00
parent e542809569
commit d6fad97fe7

View File

@ -8,8 +8,15 @@
let s:JOB = SpaceVim#api#import('job')
let s:NOTI = SpaceVim#api#import('notify')
let s:push_jobid = 0
function! git#push#run(...) abort
if s:push_jobid != 0
call s:NOTI.notify('previous push not finished')
return
endif
let s:NOTI.notify_max_width = float2nr( &columns * 0.3)
let s:std_data = {
\ 'stderr' : [],
@ -19,13 +26,18 @@ function! git#push#run(...) abort
if len(a:1) > 0
let cmd += a:1
endif
call s:JOB.start(cmd, {
let s:push_jobid = s:JOB.start(cmd, {
\ 'on_stdout' : function('s:on_stdout'),
\ 'on_stderr' : function('s:on_stderr'),
\ 'on_exit' : function('s:on_exit'),
\ }
\ )
if s:push_jobid == -1
call s:NOTI.notify('`git` is not executable')
let s:push_jobid = 0
endif
endfunction
function! s:on_exit(id, data, event) abort
@ -40,6 +52,7 @@ function! s:on_exit(id, data, event) abort
call s:NOTI.notify(line)
endfor
endif
let s:push_jobid = 0
endfunction