Update Rakefile to manage pathogen-to-vundle upgrade
The Rakefile now detects if pathogen is installed and in that case it performs the following operations: 1. Moves vim/bundle to vim/bundle.old 2. Removes all the submodules from git config and cache 3. Initializes and updates the new submodules (zsh and bundle) 4. Runs the vundle installer that takes care of the rest
This commit is contained in:
parent
990f8b35b3
commit
5c3b05302e
64
Rakefile
64
Rakefile
@ -1,4 +1,5 @@
|
||||
require 'rake'
|
||||
require 'fileutils'
|
||||
|
||||
desc "Hook our dotfiles into system-standard positions."
|
||||
task :install => [:submodule_init, :submodules] do
|
||||
@ -18,7 +19,10 @@ task :install => [:submodule_init, :submodules] do
|
||||
file_operation(Dir.glob('ctags/*')) if want_to_install?('ctags config (better js/ruby support)')
|
||||
file_operation(Dir.glob('tmux/*')) if want_to_install?('tmux config')
|
||||
file_operation(Dir.glob('vimify/*')) if want_to_install?('vimification of command line tools')
|
||||
file_operation(Dir.glob('{vim,vimrc}')) if want_to_install?('vim configuration (highly recommended)')
|
||||
if want_to_install?('vim configuration (highly recommended)')
|
||||
file_operation(Dir.glob('{vim,vimrc}'))
|
||||
Rake::Task["install_vundle"].execute
|
||||
end
|
||||
|
||||
Rake::Task["install_prezto"].execute
|
||||
|
||||
@ -35,7 +39,9 @@ task :install_prezto do
|
||||
end
|
||||
end
|
||||
|
||||
task :update => [:install] do
|
||||
task :update do
|
||||
Rake::Task["vundle_migration"].execute if needs_migration_to_vundle?
|
||||
Rake::Task["install"]
|
||||
#TODO: for now, we do the same as install. But it would be nice
|
||||
#not to clobber zsh files
|
||||
end
|
||||
@ -62,6 +68,49 @@ task :submodules do
|
||||
end
|
||||
end
|
||||
|
||||
desc "Performs migration from pathogen to vundle"
|
||||
task :vundle_migration do
|
||||
puts "======================================================"
|
||||
puts "Migrating from pathogen to vundle vim plugin manager. "
|
||||
puts "This will move the old .vim/bundle directory to"
|
||||
puts ".vim/bundle.old and replacing all your vim plugins with"
|
||||
puts "the standard set of plugins. You will then be able to "
|
||||
puts "manage your vim's plugin configuration by editing the "
|
||||
puts "file .vim/vundles.vim"
|
||||
puts "======================================================"
|
||||
|
||||
Dir.glob(File.join('vim', 'bundle','**')) do |sub_path|
|
||||
run %{git config -f #{File.join('.git', 'config')} --remove-section submodule.#{sub_path}}
|
||||
# `git rm --cached #{sub_path}`
|
||||
FileUtils.rm_rf(File.join('.git', 'modules', sub_path))
|
||||
end
|
||||
FileUtils.mv(File.join('vim','bundle'), File.join('vim', 'bundle.old'))
|
||||
run %{
|
||||
cd $HOME/.yadr
|
||||
git clone https://github.com/gmarik/vundle.git #{File.join('vim','bundle', 'vundle')}
|
||||
}
|
||||
end
|
||||
|
||||
desc "Runs Vundle installer in a clean vim environment"
|
||||
task :install_vundle do
|
||||
puts "======================================================"
|
||||
puts "Installing vundle."
|
||||
puts "The installer will now proceed to run BundleInstall."
|
||||
puts "Due to a bug, the installer may report some errors"
|
||||
puts "when installing the plugin 'syntastic'. Fortunately"
|
||||
puts "Syntastic will install and work properly despite the"
|
||||
puts "errors so please just ignore them and let's hope for"
|
||||
puts "an update that fixex the problem!"
|
||||
puts "======================================================"
|
||||
|
||||
puts ""
|
||||
puts "Press a key to continue"
|
||||
STDIN.getc
|
||||
|
||||
system "vim --noplugin -u vim/vundles.vim -N \"+set hidden\" \"+syntax on\" +BundleClean +BundleInstall +qall"
|
||||
|
||||
end
|
||||
|
||||
task :default => 'install'
|
||||
|
||||
|
||||
@ -194,6 +243,17 @@ def file_operation(files, method = :symlink)
|
||||
end
|
||||
end
|
||||
|
||||
def needs_migration_to_vundle?
|
||||
File.exists? File.join('vim', 'bundle', 'tpope-vim-pathogen')
|
||||
end
|
||||
|
||||
|
||||
def list_vim_submodules
|
||||
result=`git submodule -q foreach 'echo $name"||"\`git remote -v | awk "END{print \\\\\$2}"\`'`.select{ |line| line =~ /^vim.bundle/ }.map{ |line| line.split('||') }
|
||||
Hash[*result.flatten]
|
||||
end
|
||||
|
||||
|
||||
def success_msg(action)
|
||||
puts ""
|
||||
puts " _ _ _ "
|
||||
|
Loading…
Reference in New Issue
Block a user