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

Add option to allow locking a plugin to a specific revision #594

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions autoload/vundle.vim
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ if (has('signs'))
sign define Vu_deleted text=- texthl=Comment
sign define Vu_helptags text=* texthl=Comment
sign define Vu_pinned text== texthl=Comment
sign define Vu_detached text=@ texthl=Comment
endif

" Set up Vundle. This function has to be called from the users vimrc file.
Expand Down
17 changes: 17 additions & 0 deletions autoload/vundle/config.vim
Original file line number Diff line number Diff line change
Expand Up @@ -278,4 +278,21 @@ func! s:bundle.is_pinned()
return get(self, 'pinned')
endf

" ---------------------------------------------------------------------------
" Return HEAD to the specified revision, if one exists, and check if
" it's detached
"
" return -- 1 if the bundle is detached, 0 otherwise
" ---------------------------------------------------------------------------
func! s:bundle.is_detached()
let cmd = 'cd '.vundle#installer#shellesc(self.path())
let rev = get(self, 'rev', '')
if (rev != '')
let cmd = cmd.' && git checkout -q '.vundle#installer#shellesc(self.rev)
endif
let cmd = cmd.' && git status -b --porcelain'
let cmd = vundle#installer#shellesc_cd(cmd)
return system(cmd) =~# '^## HEAD'
endf

" vim: set expandtab sts=2 ts=2 sw=2 tw=78 norl:
8 changes: 8 additions & 0 deletions autoload/vundle/installer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ func! vundle#installer#run(func_name, name, ...) abort
echo n.' regenerated'
elseif 'pinned' == status
echo n.' pinned'
elseif 'detached' == status
echo n. ' HEAD detached'
elseif 'error' == status
echohl Error
echo 'Error processing '.n
Expand Down Expand Up @@ -416,6 +418,10 @@ func! s:make_sync_command(bang, bundle) abort
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 rev = get(a:bundle, 'rev', '')
if (rev != '')
let cmd = cmd.' -b '.vundle#installer#shellesc(rev)
endif
let initial_sha = ''
endif
return [cmd, initial_sha]
Expand All @@ -439,6 +445,8 @@ func! s:sync(bang, bundle) abort
" Do not sync if this bundle is pinned
if a:bundle.is_pinned()
return 'pinned'
elseif a:bundle.is_detached()
return 'detached'
endif

let [ cmd, initial_sha ] = s:make_sync_command(a:bang, a:bundle)
Expand Down
15 changes: 15 additions & 0 deletions doc/vundle.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,21 @@ control systems other than git, but the user is responsible for cloning and
keeping up to date. It also allows the users to stay in the current version of
a plugin that might have previously been updated by Vundle.

The 'rev' option
----------------

The revision (branch or tag) you want to follow.

For example:
>
Plugin 'git_URI', 'branch or tag name'
or
>
Plugin 'git_URI', {'rev': 'branch or tag name'}

Note that this option will try to checkout the revision specified
everytime you install or update a plugin.

Please note that the URI will be treated the same as for any other plugins, so
only the last part of it will be added to the |runtimepath|. The user is
advised to use this flag only with single word URIs to avoid confusion.
Expand Down