13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/git/multiple/parallel_task.rb', line 13
def start(directories, command, options)
git_command = build_git_cmd(command, options)
func = block_given? ? Proc.new(&block) : proc {true}
h = HighLine.new
Parallel.each(directories, in_threads: options[:jobs]) do |dirname|
Dir::chdir(dirname)
disp_dirname = dirname[%r{^#{options[:dirname]}/(.*)$}xo, 1]
disp_dirname = options[:dirname] if dirname == options[:dirname]
result = ""
if options[:"no-color"]
result << "result git #{command} ::: #{disp_dirname}" << "\n"
else
result << "#{h.color("result", :black,:on_green)} " <<
"#{h.color("git #{command}", :magenta)} " <<
"::: " <<
"#{h.color(disp_dirname, :yellow)}" <<
"\n"
end
result << %x{#{git_command} 2>&1}
result << "\n"
next unless func.call(dirname, result)
puts result
end
end
|