Skip to content

Instantly share code, notes, and snippets.

@dysinger
Created November 22, 2009 17:54
Show Gist options
  • Select an option

  • Save dysinger/240648 to your computer and use it in GitHub Desktop.

Select an option

Save dysinger/240648 to your computer and use it in GitHub Desktop.
namespace(:git) do
def all
`find . -name .git -type d`.reject {|d| d =~ /.hudson.*/}.each do |prj|
Dir.chdir(File.dirname(File.expand_path(prj))) do |d|
puts(d)
begin
yield
rescue Exception => e
puts(e.message)
end
end
end
end
desc "update all repos"
task(:update) do
all do
`git remote update`
`git svn fetch` unless `git config --get svn-remote.svn.url`.empty?
end
end
desc "prune all remotes"
task(:prune) do
all do
`git remote`.each do |r|
`git remote prune #{r}`
end
end
end
desc "gc all repos"
task(:gc) do
all do
`git gc --aggressive`
end
end
desc "rm deleted files"
task(:rm) do
`git status`.split("\n").each do |l|
l =~ /^#\s+deleted:\s+(.*)/ && `git rm #{$1}`
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment