Просмотр исходного кода

Allow cloning into an empty directory (#782)

Close #766

We can rely on git to check if the destination directory is empty.
Junegunn Choi 7 лет назад
Родитель
Сommit
b6050d6f03
2 измененных файлов с 14 добавлено и 2 удалено
  1. 1 1
      plug.vim
  2. 13 1
      test/workflow.vader

+ 1 - 1
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

+ 13 - 1
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