Skip to content

Commit 0507fc8

Browse files
committed
Merge pull request #476 from junegunn/tag-wildcard
Support wildcards in tag option
2 parents 3de4567 + e6ea538 commit 0507fc8

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
8989
" Using a non-master branch
9090
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
9191
92+
" Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
93+
Plug 'fatih/vim-go', { 'tag': '*' }
94+
9295
" Plugin options
9396
Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }
9497

plug.vim

+14-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
" " Using a non-master branch
2929
" Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
3030
"
31+
" " Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
32+
" Plug 'fatih/vim-go', { 'tag': '*' }
33+
"
3134
" " Plugin options
3235
" Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }
3336
"
@@ -966,8 +969,17 @@ function! s:update_finish()
966969
call s:log4(name, 'Checking out '.spec.commit)
967970
let out = s:checkout(spec)
968971
elseif has_key(spec, 'tag')
969-
call s:log4(name, 'Checking out '.spec.tag)
970-
let out = s:system('git checkout -q '.s:esc(spec.tag).' 2>&1', spec.dir)
972+
let tag = spec.tag
973+
if tag =~ '\*'
974+
let tags = s:lines(s:system('git tag --list '.string(tag).' --sort -version:refname 2>&1', spec.dir))
975+
if !v:shell_error && !empty(tags)
976+
let tag = tags[0]
977+
call s:log4(name, printf('Latest tag for %s -> %s', spec.tag, tag))
978+
call append(3, '')
979+
endif
980+
endif
981+
call s:log4(name, 'Checking out '.tag)
982+
let out = s:system('git checkout -q '.s:esc(tag).' 2>&1', spec.dir)
971983
else
972984
let branch = s:esc(get(spec, 'branch', 'master'))
973985
call s:log4(name, 'Merging origin/'.branch)
@@ -2227,4 +2239,3 @@ endif
22272239

22282240
let &cpo = s:cpo_save
22292241
unlet s:cpo_save
2230-

test/run

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ select_vim() {
104104
clone_repos
105105
prepare
106106

107+
git --version
107108
VIM=$(select_vim)
108109
echo "Selected Vim: $VIM"
109110
if [ "$1" = '!' ]; then

test/workflow.vader

+13
Original file line numberDiff line numberDiff line change
@@ -1424,3 +1424,16 @@ Execute (#371 - 'as' option):
14241424
AssertEqual ['yogo'], sort(keys(g:plugs))
14251425
AssertEqual '/tmp/gogo/', g:plugs.yogo.dir
14261426

1427+
Execute (#427 - Tag option with wildcard (requires git 1.9.2 or above)):
1428+
if str2nr(split(split(system('git --version'))[-1], '\.')[0]) < 2
1429+
Log 'tag with wildcard requires git 1.9.2 or above'
1430+
else
1431+
call plug#begin()
1432+
Plug 'junegunn/vim-easy-align', { 'tag': '2.9.*' }
1433+
call plug#end()
1434+
PlugInstall!
1435+
Log getline(1, '$')
1436+
AssertExpect! '- Latest tag for 2.9.* -> 2.9.7 (vim-easy-align)', 1
1437+
q
1438+
AssertEqual '2.9.7', GitTag('vim-easy-align')
1439+
endif

0 commit comments

Comments
 (0)