Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Developed plugin version selection feature #681

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
doc/tags
.netrwhist
*.swp
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
Plugin 'ascenator/L9', {'name': 'newL9'}
" Specific a plugin version (works with releases and tags)
Plugin 'kien/ctrlp.vim', {'version': '1.79'}

" All of your Plugins must be added before the following line
call vundle#end() " required
Expand Down
36 changes: 30 additions & 6 deletions autoload/vundle/installer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -405,17 +405,41 @@ func! s:make_sync_command(bang, bundle) abort
return ['', '']
endif

let cmd_parts = [
\ 'cd '.vundle#installer#shellesc(a:bundle.path()),
\ 'git pull',
\ 'git submodule update --init --recursive',
\ ]
let cmd_parts = ['cd '.vundle#installer#shellesc(a:bundle.path())]
if (has_key(a:bundle, 'version'))
echo "Processing '".a:bundle.name."' version ".a:bundle.version
call extend(cmd_parts, [
\ 'git fetch',
\ 'git checkout tags/'.vundle#installer#shellesc(a:bundle.version),
\ ])
else
call extend(cmd_parts, [
\ 'git checkout master',
\ 'git pull',
\ ])
endif
call add(cmd_parts, 'git submodule update --init --recursive')

let cmd = join(cmd_parts, ' && ')
let cmd = vundle#installer#shellesc_cd(cmd)

let initial_sha = s:get_current_sha(a:bundle)
else
let cmd = 'git clone --recursive '.vundle#installer#shellesc(a:bundle.uri).' '.vundle#installer#shellesc(a:bundle.path())
let cmd_parts = [
\ 'git clone --recursive '.vundle#installer#shellesc(a:bundle.uri).' '.vundle#installer#shellesc(a:bundle.path()),
\ ]

if (has_key(a:bundle, 'version'))
echo "Processing '".a:bundle.name."' version ".a:bundle.version
call extend(cmd_parts, [
\ 'cd '.vundle#installer#shellesc(a:bundle.path()),
\ 'git checkout tags/'.vundle#installer#shellesc(a:bundle.version),
\ ])
endif

let cmd = join(cmd_parts, ' && ')
let cmd = vundle#installer#shellesc_cd(cmd)

let initial_sha = ''
endif
return [cmd, initial_sha]
Expand Down
1 change: 1 addition & 0 deletions test/end2end/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vim
10 changes: 10 additions & 0 deletions test/end2end/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# End To End Tests

#### What is this?!?
These are end to end tests written in bash. They need bash, vim and git to be run.
They use real internet connection to download plugins from github, so you cannot run them without it.

#### To run a specific test:
```bash
$ bash test/end2end/nameOfTest.sh
```
36 changes: 36 additions & 0 deletions test/end2end/installSpecificPluginTagVersionTest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${SCRIPT_DIR}/testUtils.sh"
cd $SCRIPT_DIR

# SOME CONSTANTS TO CONSTANTLY BE UPDATED
VIM_FUGITIVE_CURRENT_VERSION="v2.2-71-gaac85a2"
VIM_SURROUND_CURRENT_VERSION="v2.1-9-ge49d6c2"

# 0. CLEAN
clean

# 1. INSTALL VUNDLE LOCALLY
deployThisVundle

# 2.1 INSTALL BUNDLES FROM FIRST LOCAL vimrc
bundlesInstallUsing ${SCRIPT_DIR}/vimrc1

# 2.2 CHECK PLUGINS
checkPluginPresenceAndVersion "vim-surround" "v2.1" # custom specified tag
checkPluginPresenceAndVersion "vim-fugitive" $VIM_FUGITIVE_CURRENT_VERSION # actual master version
checkPluginPresenceAndVersion "customFolderName" "1.79" # custom name and specified tag
checkPluginPresenceAndVersion "vim-javascript" "v0.9.0" # another custom specified tag

# 3.1. INSTALL BUNDLES FROM SECOND LOCAL vimrc
bundlesInstallUsing ${SCRIPT_DIR}/vimrc2

# 3.2 CHECK PLUGINS
checkPluginPresenceAndVersion "vim-surround" $VIM_SURROUND_CURRENT_VERSION # removed specified version
checkPluginPresenceAndVersion "vim-fugitive" "v1.2" # added custom specified version
checkPluginPresenceAndVersion "ctrlp.vim" "1.78" # removed custom name and changed tag version
checkPluginPresenceAndVersion "vim-javascript" "v0.9.0" # nothing changed here

# 4 GREEN BAR AND CLEAN
successPrintAndClean
48 changes: 48 additions & 0 deletions test/end2end/testUtils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
NC='\033[0m' # No Color
BUNDLES_FOLDER="${SCRIPT_DIR}/.vim/bundle/"

function successPrintAndClean {
GREEN='\033[42m'
printf "${GREEN} Green bar!! :-) ${NC}\n"
clean
}

function errorPrintAndClean {
RED='\033[41m'
printf "${RED} $1 :-( ${NC}\n"
clean
}

function clean {
rm -rf ${SCRIPT_DIR}/.vim
}

function deployThisVundle {
mkdir -p ${SCRIPT_DIR}/.vim/bundle/vundle
cp -r ${SCRIPT_DIR}/../../* ./.vim/bundle/vundle/ 2> /dev/null
}

function bundlesInstallUsing {
vim -u $1 +BundleInstall! +qall
}

function checkPluginPresenceAndVersion {
name=$1
expectedVersion=$2
pluginFolder=${BUNDLES_FOLDER}${name}

if [ ! -d $pluginFolder ]; then
errorPrintAndClean "No plugin folder for ${name}!!"
exit
fi

cd $pluginFolder
gitDescribe=$(git describe --tags)

if [ "$gitDescribe" != "$expectedVersion" ]; then
errorPrintAndClean "Wrong plugin version for ${name} (${gitDescribe})!"
exit
fi

cd $SCRIPT_DIR
}
14 changes: 14 additions & 0 deletions test/end2end/vimrc1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
set nocompatible
filetype off

set rtp=./.vim/
set rtp+=./.vim/bundle/vundle/
call vundle#begin('./.vim/bundle')

Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-surround', {'version': 'v2.1'}
Plugin 'kien/ctrlp.vim', {'name': 'customFolderName', 'version': '1.79'}
Plugin 'pangloss/vim-javascript', {'version': 'v0.9.0'}


call vundle#end()
13 changes: 13 additions & 0 deletions test/end2end/vimrc2
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
set nocompatible
filetype off

set rtp=./.vim/
set rtp+=./.vim/bundle/vundle/
call vundle#begin('./.vim/bundle')

Plugin 'tpope/vim-fugitive', {'version': 'v1.2'}
Plugin 'tpope/vim-surround'
Plugin 'kien/ctrlp.vim', {'version': '1.78'}
Plugin 'pangloss/vim-javascript', {'version': 'v0.9.0'}

call vundle#end()