Skip to content

Instantly share code, notes, and snippets.

@jeremywrowe
Created February 4, 2011 12:38
Show Gist options
  • Save jeremywrowe/811065 to your computer and use it in GitHub Desktop.
Save jeremywrowe/811065 to your computer and use it in GitHub Desktop.
update all of your git and svn projects from a root directory
#!/usr/bin/ruby
require 'fileutils'
include FileUtils
here = File.expand_path(File.dirname(__FILE__))
git_dirs = Dir.glob("#{here}/*/.git")
svn_dirs = Dir.glob("#{here}/*/.svn")
def git_pull(path)
cd path
`git pull`
end
def svn_update(path)
cd path
`svn update`
end
puts "Performing a GIT pull.." if git_dirs.size > 0
git_dirs.each do |git_dir|
path = git_dir.sub!(/\.git/, "")
puts "Pulling from: #{path}"
git_pull path
end
puts "Performing a SVN update.." if svn_dirs.size > 0
svn_dirs.each do |svn_dir|
path = svn_dir.sub!(/\.svn/, "")
puts "Updating #{path}"
svn_update path
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment