Skip to content

Instantly share code, notes, and snippets.

@tulios
Created July 8, 2011 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tulios/1071840 to your computer and use it in GitHub Desktop.
Save tulios/1071840 to your computer and use it in GitHub Desktop.
Atualiza todos os projetos git de um determinado diretório
#!/usr/bin/env ruby
#encoding: utf-8
require 'rubygems'
require 'terminal-display-colors'
projects_dir = File.expand_path(ARGV[0] || "~/Projetos")
puts "ProjectsDir: #{projects_dir}\n".blue
projects = Dir.new(projects_dir).entries.
select { |path| File.directory?(File.expand_path(File.join(projects_dir, path))) }.
select {|path| not ['.', '..'].member?(path)}
git_projects = projects.select {|path| File.directory?(File.expand_path(File.join(projects_dir, path, '.git')))}
git_projects.each do |path|
full_path = File.expand_path(File.join(projects_dir, path))
puts "Updating #{full_path}".green
Dir.chdir(full_path)
system("git pull --rebase")
puts "\n"
end
puts "done.".blue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment