Skip to content

Commit

Permalink
parallel versions of rgit
Browse files Browse the repository at this point in the history
  • Loading branch information
adagios committed Apr 7, 2015
1 parent 146825c commit f6f1bef
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
32 changes: 32 additions & 0 deletions bin/prgit
@@ -0,0 +1,32 @@
#!/usr/bin/env ruby

require "thread"

threads = []
lock = Mutex.new

args = ARGV.join(" ")

Dir.foreach('.') do |f|
next unless File.directory? f #only dirs
next if f =~ /\.+/ #skip . and ..

if Dir.new(f).include?('.git')
threads << Thread.new do

output = `cd #{f} && git #{args} 2>&1`

unless output.empty? && $?.success?
lock.synchronize do
puts f
puts "-"*f.size
puts output
puts "\n"
end
end
end
end

end

threads.map(&:join)
41 changes: 41 additions & 0 deletions bin/qrgit
@@ -0,0 +1,41 @@
#!/usr/bin/env ruby

require "thread"

jobs = Queue.new
threads = []
lock = Mutex.new

args = ARGV.join(" ")

Dir.foreach('.') do |f|
next unless File.directory? f #only dirs
next if f =~ /\.+/ #skip . and ..

if Dir.new(f).include?('.git')
jobs.push f
end
end

threads = 4.times.map do
Thread.new do
begin
while f = jobs.pop(true) do
output = `cd #{f} && git #{args} 2>&1`

unless output.empty? && $?.success?
lock.synchronize do
puts f
puts "-"*f.size
puts output
puts "\n"
end
end
end
rescue ThreadError
end

end
end

threads.map(&:join)

0 comments on commit f6f1bef

Please sign in to comment.