Skip to content

Instantly share code, notes, and snippets.

@tomz
Created June 15, 2010 22:03
Show Gist options
  • Save tomz/439811 to your computer and use it in GitHub Desktop.
Save tomz/439811 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# script to refresh local git or svn repos
def pull_or_update (level = 1)
if (level > 0)
Dir.glob("*").each {|e|
Dir.chdir(e) do
if File.directory?(".git")
puts "\n========== pulling #{e} =========="
system 'git pull'
elsif File.directory?(".svn")
puts "\n========== updating #{e} =========="
system 'svn update'
else
pull_or_update(level-1)
end
end if File.directory?(e)
}
end
end
level = ARGV[0] || 2 # default to 2 levels down
pull_or_update level
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment