Skip to content

Instantly share code, notes, and snippets.

@spicycode
Created July 22, 2009 01:05
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 spicycode/151732 to your computer and use it in GitHub Desktop.
Save spicycode/151732 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'active_support'
require 'yaml'
require 'fileutils'
require 'pathname'
RootPath = Pathname.new('/Volumes/space/github_mirror')
GithubInfo = YAML.load_file(RootPath.join('the_parts_horror.yml'))
def make_with_the_awesome(*args)
command = args.join(' ')
if command.nil?
puts "No command given, just cloning any repos not already on disk"
end
FileUtils.cd(RootPath) do
GithubInfo.each do |username, repos|
repos.each do |repo|
repo_path = "#{username}-#{repo}"
if File.exist?(repo_path)
FileUtils.cd(repo_path) do
ICommandTheTo command, repo_path
end
else
clone_url = "git://github.com/#{username}/#{repo}.git"
ICommandTheTo "git clone #{clone_url} #{repo_path} --quiet"
end
end
end
end
end
def ICommandTheTo(command, repo_path=nil)
return if command.blank?
path = repo_path ? " in #{repo_path}" : nil
puts "Executing '#{command}'#{path}"
puts '-' * 40
system command
puts
end
make_with_the_awesome(ARGV)
# Now you can just run it to clone all the defined repos:
ruby clonus.rb
# Want to update?
ruby clonus.rb git pull
# Arbitrary command?
ruby clonus.rb ls -l
---
280north:
- aristo
actionrails:
- modporter
ahoward:
- main
- testy
alloy:
- kicker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment