From b6050d6f03f3e2792589535249e3c997d3e94461 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Wed, 12 Sep 2018 13:45:38 +0900 Subject: [PATCH] Allow cloning into an empty directory (#782) Close #766 We can rely on git to check if the destination directory is empty. --- plug.vim | 2 +- test/workflow.vader | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/plug.vim b/plug.vim index 3b49660..db1f615 100644 --- a/plug.vim +++ b/plug.vim @@ -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 diff --git a/test/workflow.vader b/test/workflow.vader index d76a13b..5bd14e1 100644 --- a/test/workflow.vader +++ b/test/workflow.vader @@ -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