Skip to content

Commit

Permalink
Allow cloning into an empty directory (#782)
Browse files Browse the repository at this point in the history
Close #766

We can rely on git to check if the destination directory is empty.
  • Loading branch information
junegunn committed Sep 12, 2018
1 parent 7f8fdd0 commit b6050d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plug.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion test/workflow.vader
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit b6050d6

Please sign in to comment.