Skip to content

Commit 597a2d3

Browse files
committed
Developed plugin version selection feature
1 parent 5f70ae6 commit 597a2d3

File tree

9 files changed

+155
-6
lines changed

9 files changed

+155
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
doc/tags
22
.netrwhist
3+
*.swp

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
7373
" Avoid a name conflict with L9
7474
Plugin 'user/L9', {'name': 'newL9'}
75+
" Specific a plugin version (works with releases and tags)
76+
Plugin 'kien/ctrlp.vim', {'version': '1.79'}
7577
7678
" All of your Plugins must be added before the following line
7779
call vundle#end() " required

autoload/vundle/installer.vim

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,17 +405,41 @@ func! s:make_sync_command(bang, bundle) abort
405405
return ['', '']
406406
endif
407407

408-
let cmd_parts = [
409-
\ 'cd '.vundle#installer#shellesc(a:bundle.path()),
410-
\ 'git pull',
411-
\ 'git submodule update --init --recursive',
412-
\ ]
408+
let cmd_parts = ['cd '.vundle#installer#shellesc(a:bundle.path())]
409+
if (has_key(a:bundle, 'version'))
410+
echo "Processing '".a:bundle.name."' version ".a:bundle.version
411+
call extend(cmd_parts, [
412+
\ 'git fetch',
413+
\ 'git checkout tags/'.vundle#installer#shellesc(a:bundle.version),
414+
\ ])
415+
else
416+
call extend(cmd_parts, [
417+
\ 'git checkout master',
418+
\ 'git pull',
419+
\ ])
420+
endif
421+
call add(cmd_parts, 'git submodule update --init --recursive')
422+
413423
let cmd = join(cmd_parts, ' && ')
414424
let cmd = vundle#installer#shellesc_cd(cmd)
415425

416426
let initial_sha = s:get_current_sha(a:bundle)
417427
else
418-
let cmd = 'git clone --recursive '.vundle#installer#shellesc(a:bundle.uri).' '.vundle#installer#shellesc(a:bundle.path())
428+
let cmd_parts = [
429+
\ 'git clone --recursive '.vundle#installer#shellesc(a:bundle.uri).' '.vundle#installer#shellesc(a:bundle.path()),
430+
\ ]
431+
432+
if (has_key(a:bundle, 'version'))
433+
echo "Processing '".a:bundle.name."' version ".a:bundle.version
434+
call extend(cmd_parts, [
435+
\ 'cd '.vundle#installer#shellesc(a:bundle.path()),
436+
\ 'git checkout tags/'.vundle#installer#shellesc(a:bundle.version),
437+
\ ])
438+
endif
439+
440+
let cmd = join(cmd_parts, ' && ')
441+
let cmd = vundle#installer#shellesc_cd(cmd)
442+
419443
let initial_sha = ''
420444
endif
421445
return [cmd, initial_sha]

test/end2end/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vim

test/end2end/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# End To End Tests
2+
3+
#### What is this?!?
4+
These are end to end tests written in bash. They need bash, vim and git to be run.
5+
They use real internet connection to download plugins from github, so you cannot run them without it.
6+
7+
#### To run a specific test:
8+
```bash
9+
$ bash test/end2end/nameOfTest.sh
10+
```
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4+
source "${SCRIPT_DIR}/testUtils.sh"
5+
cd $SCRIPT_DIR
6+
7+
# SOME CONSTANTS TO CONSTANTLY BE UPDATED
8+
VIM_FUGITIVE_CURRENT_VERSION="v2.2-71-gaac85a2"
9+
VIM_SURROUND_CURRENT_VERSION="v2.1-9-ge49d6c2"
10+
11+
# 0. CLEAN
12+
clean
13+
14+
# 1. INSTALL VUNDLE LOCALLY
15+
deployThisVundle
16+
17+
# 2.1 INSTALL BUNDLES FROM FIRST LOCAL vimrc
18+
bundlesInstallUsing ${SCRIPT_DIR}/vimrc1
19+
20+
# 2.2 CHECK PLUGINS
21+
checkPluginPresenceAndVersion "vim-surround" "v2.1" # custom specified tag
22+
checkPluginPresenceAndVersion "vim-fugitive" $VIM_FUGITIVE_CURRENT_VERSION # actual master version
23+
checkPluginPresenceAndVersion "customFolderName" "1.79" # custom name and specified tag
24+
checkPluginPresenceAndVersion "vim-javascript" "v0.9.0" # another custom specified tag
25+
26+
# 3.1. INSTALL BUNDLES FROM SECOND LOCAL vimrc
27+
bundlesInstallUsing ${SCRIPT_DIR}/vimrc2
28+
29+
# 3.2 CHECK PLUGINS
30+
checkPluginPresenceAndVersion "vim-surround" $VIM_SURROUND_CURRENT_VERSION # removed specified version
31+
checkPluginPresenceAndVersion "vim-fugitive" "v1.2" # added custom specified version
32+
checkPluginPresenceAndVersion "ctrlp.vim" "1.78" # removed custom name and changed tag version
33+
checkPluginPresenceAndVersion "vim-javascript" "v0.9.0" # nothing changed here
34+
35+
# 4 GREEN BAR AND CLEAN
36+
successPrintAndClean

test/end2end/testUtils.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
NC='\033[0m' # No Color
2+
BUNDLES_FOLDER="${SCRIPT_DIR}/.vim/bundle/"
3+
4+
function successPrintAndClean {
5+
GREEN='\033[42m'
6+
printf "${GREEN} Green bar!! :-) ${NC}\n"
7+
clean
8+
}
9+
10+
function errorPrintAndClean {
11+
RED='\033[41m'
12+
printf "${RED} $1 :-( ${NC}\n"
13+
clean
14+
}
15+
16+
function clean {
17+
rm -rf ${SCRIPT_DIR}/.vim
18+
}
19+
20+
function deployThisVundle {
21+
mkdir -p ${SCRIPT_DIR}/.vim/bundle/vundle
22+
cp -r ${SCRIPT_DIR}/../../* ./.vim/bundle/vundle/ 2> /dev/null
23+
}
24+
25+
function bundlesInstallUsing {
26+
vim -u $1 +BundleInstall! +qall
27+
}
28+
29+
function checkPluginPresenceAndVersion {
30+
name=$1
31+
expectedVersion=$2
32+
pluginFolder=${BUNDLES_FOLDER}${name}
33+
34+
if [ ! -d $pluginFolder ]; then
35+
errorPrintAndClean "No plugin folder for ${name}!!"
36+
exit
37+
fi
38+
39+
cd $pluginFolder
40+
gitDescribe=$(git describe --tags)
41+
42+
if [ "$gitDescribe" != "$expectedVersion" ]; then
43+
errorPrintAndClean "Wrong plugin version for ${name} (${gitDescribe})!"
44+
exit
45+
fi
46+
47+
cd $SCRIPT_DIR
48+
}

test/end2end/vimrc1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
set nocompatible
2+
filetype off
3+
4+
set rtp=./.vim/
5+
set rtp+=./.vim/bundle/vundle/
6+
call vundle#begin('./.vim/bundle')
7+
8+
Plugin 'tpope/vim-fugitive'
9+
Plugin 'tpope/vim-surround', {'version': 'v2.1'}
10+
Plugin 'kien/ctrlp.vim', {'name': 'customFolderName', 'version': '1.79'}
11+
Plugin 'pangloss/vim-javascript', {'version': 'v0.9.0'}
12+
13+
14+
call vundle#end()

test/end2end/vimrc2

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
set nocompatible
2+
filetype off
3+
4+
set rtp=./.vim/
5+
set rtp+=./.vim/bundle/vundle/
6+
call vundle#begin('./.vim/bundle')
7+
8+
Plugin 'tpope/vim-fugitive', {'version': 'v1.2'}
9+
Plugin 'tpope/vim-surround'
10+
Plugin 'kien/ctrlp.vim', {'version': '1.78'}
11+
Plugin 'pangloss/vim-javascript', {'version': 'v0.9.0'}
12+
13+
call vundle#end()

0 commit comments

Comments
 (0)