1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 07:40:05 +08:00

Fix build

This commit is contained in:
wsdjeg 2017-04-22 15:19:13 +08:00
parent 3e8a2dddc1
commit e36df642c8
2 changed files with 46 additions and 13 deletions

View File

@ -90,7 +90,6 @@ function! s:self.start(argv, ...) abort
call extend(self.jobs, {id : job}) call extend(self.jobs, {id : job})
return id return id
else else
call self.warn()
if len(a:000) > 0 if len(a:000) > 0
let opts = a:1 let opts = a:1
else else

View File

@ -23,6 +23,7 @@ let s:building_repos = {}
let s:ui_buf = {} let s:ui_buf = {}
let s:plugin_manager_buffer = 0 let s:plugin_manager_buffer = 0
let s:plugin_manager_buffer_lines = [] let s:plugin_manager_buffer_lines = []
let s:jobpid = 0
" install plugin manager " install plugin manager
function! s:install_manager() abort function! s:install_manager() abort
@ -168,6 +169,7 @@ function! SpaceVim#plugins#manager#update(...) abort
elseif status == 1 elseif status == 1
return return
endif endif
redraw!
let s:pct = 0 let s:pct = 0
let s:pct_done = 0 let s:pct_done = 0
let s:plugins = a:0 == 0 ? sort(keys(dein#get())) : sort(copy(a:1)) let s:plugins = a:0 == 0 ? sort(keys(dein#get())) : sort(copy(a:1))
@ -217,19 +219,27 @@ endfunction
" here if a:data == 0, git pull succeed " here if a:data == 0, git pull succeed
function! s:on_pull_exit(id, data, event) abort function! s:on_pull_exit(id, data, event) abort
if a:data == 0 && a:event ==# 'exit' if a:id == -1
call s:msg_on_updated_done(s:pulling_repos[a:id].name) let id = s:jobpid
else else
call s:msg_on_updated_failed(s:pulling_repos[a:id].name) let id = a:id
endif endif
if get(s:pulling_repos[a:id], 'build', '') !=# '' if a:data == 0 && a:event ==# 'exit'
call s:build(s:pulling_repos[a:id]) call s:msg_on_updated_done(s:pulling_repos[id].name)
else
call s:msg_on_updated_failed(s:pulling_repos[id].name)
endif
if a:id == -1
redraw!
endif
if get(s:pulling_repos[id], 'build', '') !=# ''
call s:build(s:pulling_repos[id])
else else
let s:pct_done += 1 let s:pct_done += 1
call s:set_buf_line(s:plugin_manager_buffer, 1, 'Updating plugins (' . s:pct_done . '/' . s:total . ')') call s:set_buf_line(s:plugin_manager_buffer, 1, 'Updating plugins (' . s:pct_done . '/' . s:total . ')')
call s:set_buf_line(s:plugin_manager_buffer, 2, s:status_bar()) call s:set_buf_line(s:plugin_manager_buffer, 2, s:status_bar())
endif endif
call remove(s:pulling_repos, string(a:id)) call remove(s:pulling_repos, string(id))
if !empty(s:plugins) if !empty(s:plugins)
let name = s:LIST.shift(s:plugins) let name = s:LIST.shift(s:plugins)
if name ==# 'SpaceVim' if name ==# 'SpaceVim'
@ -242,7 +252,7 @@ function! s:on_pull_exit(id, data, event) abort
endif endif
call s:pull(repo) call s:pull(repo)
endif endif
if empty(s:pulling_repos) && empty(s:building_repos) if empty(s:pulling_repos) && empty(s:building_repos) && !exists('s:recache_done')
" TODO add elapsed time info. " TODO add elapsed time info.
call s:set_buf_line(s:plugin_manager_buffer, 1, 'Updated. Elapsed time: ' call s:set_buf_line(s:plugin_manager_buffer, 1, 'Updated. Elapsed time: '
\ . split(reltimestr(reltime(s:start_time)))[0] . ' sec.') \ . split(reltimestr(reltime(s:start_time)))[0] . ' sec.')
@ -250,6 +260,9 @@ function! s:on_pull_exit(id, data, event) abort
if g:spacevim_plugin_manager ==# 'dein' if g:spacevim_plugin_manager ==# 'dein'
call dein#recache_runtimepath() call dein#recache_runtimepath()
endif endif
if a:id == -1
let s:recache_done = 1
endif
endif endif
endfunction endfunction
@ -327,12 +340,23 @@ function! s:pull(repo) abort
let s:pct += 1 let s:pct += 1
let s:ui_buf[a:repo.name] = s:pct let s:ui_buf[a:repo.name] = s:pct
let argv = ['git', '-C', a:repo.path, 'pull'] let argv = ['git', '-C', a:repo.path, 'pull']
let jobid = s:JOB.start(argv,{ if s:JOB.vim_job || s:JOB.nvim_job
\ 'on_exit' : function('s:on_pull_exit') let jobid = s:JOB.start(argv,{
\ }) \ 'on_exit' : function('s:on_pull_exit')
if jobid != 0 \ })
let s:pulling_repos[jobid] = a:repo if jobid != 0
let s:pulling_repos[jobid] = a:repo
call s:msg_on_start(a:repo.name)
endif
else
let s:jobpid += 1
let s:pulling_repos[s:jobpid] = a:repo
call s:msg_on_start(a:repo.name) call s:msg_on_start(a:repo.name)
redraw!
call s:JOB.start(argv,{
\ 'on_exit' : function('s:on_pull_exit')
\ })
endif endif
endfunction endfunction
@ -353,6 +377,7 @@ endfunction
function! s:build(repo) abort function! s:build(repo) abort
let argv = type(a:repo.build) != 4 ? a:repo.build : s:get_build_argv(a:repo.build) let argv = type(a:repo.build) != 4 ? a:repo.build : s:get_build_argv(a:repo.build)
if s:JOB.vim_job || s:JOB.nvim_job
let jobid = s:JOB.start(argv,{ let jobid = s:JOB.start(argv,{
\ 'on_exit' : function('s:on_build_exit'), \ 'on_exit' : function('s:on_build_exit'),
\ 'cwd' : a:repo.path, \ 'cwd' : a:repo.path,
@ -361,6 +386,15 @@ function! s:build(repo) abort
let s:building_repos[jobid] = a:repo let s:building_repos[jobid] = a:repo
call s:msg_on_build_start(a:repo.name) call s:msg_on_build_start(a:repo.name)
endif endif
else
let s:building_repos[s:jobpid] = a:repo
call s:msg_on_build_start(a:repo.name)
redraw!
call s:JOB.start(argv,{
\ 'on_exit' : function('s:on_build_exit')
\ })
endif
endfunction endfunction
function! s:msg_on_build_start(name) abort function! s:msg_on_build_start(name) abort