Created
February 28, 2014 12:33
-
-
Save hkraji/9270298 to your computer and use it in GitHub Desktop.
Clean and Update all
This file contains hidden or 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 | |
require 'pp' | |
# no stdout buffering | |
STDOUT.sync = true | |
# checks for windows/unix for chaining commands | |
OS_COMMAND_CHAIN = RUBY_PLATFORM =~ /mswin|mingw|cygwin/ ? "&" : ";" | |
Dir.entries('.').select do |entry| | |
next if %w{. .. ,,}.include? entry | |
if File.directory? File.join('.', entry) | |
if File.directory? File.join('.', entry, '.git') | |
full_path = "#{Dir.pwd}/#{entry}" | |
git_dir = "--git-dir=#{full_path}/.git --work-tree=#{full_path}" | |
puts "\nUPDATING '#{full_path}' \n\n" | |
puts `git #{git_dir} clean -f #{OS_COMMAND_CHAIN} git #{git_dir} checkout . #{OS_COMMAND_CHAIN} git #{git_dir} pull origin master` | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment