Allow cloning into an empty directory (#782)

Close #766

We can rely on git to check if the destination directory is empty.
This commit is contained in:
Junegunn Choi 2018-09-12 13:45:38 +09:00 committed by GitHub
parent 7f8fdd0444
commit b6050d6f03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -1331,7 +1331,7 @@ while 1 " Without TCO, Vim stack is bound to explode
let name = keys(s:update.todo)[0]
let spec = remove(s:update.todo, name)
let new = !isdirectory(spec.dir)
let new = empty(globpath(spec.dir, '.git', 1))
call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...')
redraw

View file

@ -1511,7 +1511,7 @@ Execute (Commit hash support):
Log getline(1, '$')
AssertEqual 'x goyo.vim:', getline(5)
AssertEqual ' fatal: invalid reference: ffffffff', getline(6)
AssertEqual 0, stridx(getline(7), '- vim-emoji: HEAD is now at 9db7fcf...')
AssertEqual 0, stridx(getline(7), '- vim-emoji: HEAD is now at 9db7fcf')
let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
AssertEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
@ -1638,3 +1638,15 @@ Execute (#532 - Reuse plug window):
AssertEqual 2, winnr(), 'Current window is #2 after PlugStatus (but is '.winnr().')'
AssertEqual 2, winnr('$'), 'Three windows after PlugStatus (but got '.winnr('$').')'
q
Execute (#766 - Allow cloning into an empty directory):
let d = '/tmp/vim-plug-test/goyo-already'
call system('rm -rf ' . d)
call mkdir(d)
call plug#begin()
Plug 'junegunn/goyo.vim', { 'dir': d }
call plug#end()
PlugInstall
AssertExpect! '[=]', 1
q
unlet d