Created
July 8, 2011 13:36
-
-
Save tulios/1071840 to your computer and use it in GitHub Desktop.
Atualiza todos os projetos git de um determinado diretório
This file contains 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 | |
#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