Browse Source

Fix #139 - Use git fetch+merge instead of pull

Junegunn Choi 11 years ago
parent
commit
0e9fa672f8
4 changed files with 92 additions and 2 deletions
  1. 2 0
      .travis.yml
  2. 2 2
      plug.vim
  3. 77 0
      test/regressions.vader
  4. 11 0
      test/run

+ 2 - 0
.travis.yml

@@ -10,6 +10,8 @@ before_script: |
   make
   sudo make install
   cd -
+  git config --global user.email "you@example.com"
+  git config --global user.name "Your Name"
 
 script: |
   test/run !

+ 2 - 2
plug.vim

@@ -914,7 +914,7 @@ while 1 " Without TCO, Vim stack is bound to explode
     if valid
       if pull
         call s:spawn(name,
-          \ printf('git checkout -q %s 2>&1 && git pull --progress --no-rebase origin %s 2>&1 && git submodule update --init --recursive 2>&1',
+          \ printf('(git fetch --progress 2>&1 && git checkout -q %s 2>&1 && git merge --ff-only origin/%s 2>&1 && git submodule update --init --recursive 2>&1)',
           \ s:shellesc(spec.branch), s:shellesc(spec.branch)), { 'dir': spec.dir })
       else
         let s:jobs[name] = { 'running': 0, 'result': 'Already installed', 'error': 0 }
@@ -1125,7 +1125,7 @@ function! s:update_ruby()
               else
                 if pull
                   log.call name, 'Updating ...', :update
-                  bt.call "#{cd} #{dir} && git checkout -q #{branch} 2>&1 && (git pull --no-rebase origin #{branch} #{progress} 2>&1 && #{subm})", name, :update, nil
+                  bt.call "#{cd} #{dir} && (git fetch #{progress} 2>&1 && git checkout -q #{branch} 2>&1 && git merge --ff-only origin/#{branch} 2>&1 && #{subm})", name, :update, nil
                 else
                   [true, skip]
                 end

+ 77 - 0
test/regressions.vader

@@ -72,3 +72,80 @@ Execute (#131 Syntax error):
   silent PlugInstall
   redir END
   Assert out =~ 'Invalid plug directory: /no-permission'
+
+**********************************************************************
+Execute (#139-1 Using new remote branch):
+  " Make sure to remove the clone
+  call plug#begin('$TMPDIR/plugged')
+  call plug#end()
+  PlugClean!
+
+  " Install master branch
+  call plug#begin('$TMPDIR/plugged')
+  Plug expand('file:///$TMPDIR/new-branch')
+  call plug#end()
+  PlugUpdate
+
+  unlet! g:foo g:bar g:baz
+  call plug#load('new-branch')
+  Assert exists('g:foo'),  'g:foo should be found'
+  Assert !exists('g:bar'), 'g:bar should not be found'
+  Assert !exists('g:baz'), 'g:baz should not be found'
+
+  " Create a new branch on origin
+  call system('cd $TMPDIR/new-branch && git checkout -b new &&'
+      \. 'echo "let g:bar = 1" > plugin/bar.vim && git add plugin/bar.vim &&'
+      \. 'git commit -m second')
+
+  " We're setting up two plugins so that parallel installer is used
+  call plug#begin('$TMPDIR/plugged')
+  Plug 'junegunn/seoul256.vim'
+  Plug expand('file:///$TMPDIR/new-branch'), 'new'
+  call plug#end()
+  PlugUpdate
+  silent %y
+  Log @"
+  Assert @" !~? 'error', 'Should be able to use new remote branch: ' . @"
+
+  unlet! g:foo g:bar g:baz
+  call plug#load('new-branch')
+  Assert exists('g:foo'),  'g:foo should be found'
+  Assert exists('g:bar'),  'g:bar should be found'
+  Assert !exists('g:baz'), 'g:baz should not be found'
+
+  call PlugStatusSorted()
+
+Expect:
+  - new-branch: OK
+  - seoul256.vim: OK
+  Finished. 0 error(s).
+  [==]
+
+Execute (#139-2 Using yet another new remote branch):
+  " Create another branch on origin
+  call system('cd $TMPDIR/new-branch && git checkout master &&'
+      \. 'git checkout -b brand-new &&'
+      \. 'echo "let g:baz = 1" > plugin/baz.vim && git add plugin/baz.vim &&'
+      \. 'git commit -m thirf')
+
+  " Test Vim installer here
+  call plug#begin('$TMPDIR/plugged')
+  Plug expand('file:///$TMPDIR/new-branch'), 'brand-new'
+  call plug#end()
+  PlugUpdate
+  silent %y
+  Log @"
+  Assert @" !~? 'error', 'Should be able to use new remote branch: ' . @"
+
+  unlet! g:foo g:bar g:baz
+  call plug#load('new-branch')
+  Assert exists('g:foo'),  'g:foo should be found'
+  Assert !exists('g:bar'), 'g:bar should not be found'
+  Assert exists('g:baz'),  'g:baz should be found'
+
+  call PlugStatusSorted()
+
+Expect:
+  - new-branch: OK
+  Finished. 0 error(s).
+  [=]

+ 11 - 0
test/run

@@ -51,6 +51,7 @@ EOF
 
 init() {
   rm -rf $PLUG_FIXTURES/{xxx,yyy,z1,z2}
+  rm -rf $TMPDIR/new-branch
 
   make_dirs xxx/ xxx
   make_dirs xxx/after xxx
@@ -64,6 +65,16 @@ DOC
 
   make_dirs z1/ z1
   make_dirs z2/ z2
+
+  (
+    cd $TMPDIR
+    git init new-branch
+    cd new-branch
+    mkdir plugin
+    echo 'let g:foo = 1' > plugin/foo.vim
+    git add plugin/foo.vim
+    git commit -m initial
+  )
 }
 
 cat > /tmp/mini-vimrc << VIMRC