Created
October 24, 2012 02:15
-
-
Save squarism/3943329 to your computer and use it in GitHub Desktop.
Update All Git Vendor Repositories
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# UPDATE ALL THE THINGS! | |
# go into each all the git projects and do a `git pull` | |
# this is mainly used to update apps which use git to deliver updates | |
# for example, rbenv & vim plugins | |
# change this here thing-o below. use an asterisk glob for a bunch of submodules. | |
projects = %w( | |
~/.vim/bundle/* | |
~/.oh-my-zsh | |
~/.rbenv | |
~/.rbenv/plugins/* | |
) | |
def git_pull(path) | |
git_output = `cd #{path} && git pull` | |
status = git_output.split("\n").last | |
puts "#{path.split("/").last}: \033[33m#{status}\033[0m" | |
end | |
def sub_dirs_from(path) | |
# we need to replace the tilde with HOME if the path has globs/stars | |
dir = path.gsub /^\~/, ENV['HOME'] | |
Dir.glob(dir) | |
end | |
projects.each do |proj| | |
# if a path ends in * then we need to go into each one and do a git pull | |
if proj.match /\*$/ | |
sub_dirs_from(proj).each do |path| | |
git_pull path | |
end | |
# otherwise, just do a git pull | |
else | |
git_pull proj | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment