diff --git a/.travis.yml b/.travis.yml index 93c7e6e..682b145 100644 --- a/.travis.yml +++ b/.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 ! diff --git a/plug.vim b/plug.vim index 77fa847..c94876d 100644 --- a/plug.vim +++ b/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 diff --git a/test/regressions.vader b/test/regressions.vader index 5ea4d5e..e0f6724 100644 --- a/test/regressions.vader +++ b/test/regressions.vader @@ -72,3 +72,101 @@ 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 third') + + " 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). + [=] + +Execute (#139-3 Should fail when not possible to fast-forward): + " Commit on cloned repo + call system('cd $TMPDIR/plugged/new-branch && git checkout master &&' + \. 'touch foobar && git add foobar && git commit -m foobar') + + " Different commit on remote + call system('cd $TMPDIR/new-branch && git checkout master &&' + \. 'touch foobaz && git add foobaz && git commit -m foobaz') + + for multi in [0, 1] + call plug#begin('$TMPDIR/plugged') + if multi + Plug 'junegunn/seoul256.vim' + endif + Plug expand('file:///$TMPDIR/new-branch') + call plug#end() + PlugUpdate + silent %y + Assert @" =~ 'Not possible to fast-forward', @" + endfor diff --git a/test/run b/test/run index f9115f0..b04cef9 100755 --- a/test/run +++ b/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