Skip to content

Instantly share code, notes, and snippets.

@ik5 ik5/update.rb
Last active Dec 15, 2015

Embed
What would you like to do?
My update script for many repositories under current folder, with different scm
#!/usr/bin/env ruby
#
def update(dir, type)
Dir.chdir(dir)
puts "Going to update #{dir}"
system("#{type.to_s} pull")
Dir.chdir('..')
end
scm = [ :git, :hg ]
Dir['*'].each do |f|
if File.ftype(f) == 'directory'
scm.each do |s|
if Dir[f + "/.#{s.to_s}"][0]
update(f, s)
break
end # if Dir[f + "/.#{s.to_s}"][0]
end # scm.each do |s|
end # if File.ftype(f) == 'directory'
end # Dir['*'].each do |f|
puts 'done'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.