Skip to content

Commit

Permalink
Added threads to git updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mattboldt committed Dec 9, 2018
1 parent a398923 commit 83a4981
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 23 deletions.
2 changes: 1 addition & 1 deletion lib/guac/colors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def paint(ary)
:green
end

[color, ary.map { |r| r.colorize(color) }]
ary.map { |r| r.colorize(color) }
end

def contains?(ary, string)
Expand Down
16 changes: 9 additions & 7 deletions lib/guac/commands/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ def initialize(options)
end

def execute(input: $stdin, output: $stdout)
@repos.each do |repo|
output.puts repo.name.bold.colorize(:blue)
threads = @repos.map do |repo|
Thread.new do
response = [repo.status]
response = Colors.paint(response)
response.unshift(repo.name.bold.colorize(:blue))

response = [repo.status]

color, response = Colors.paint(response)
output.puts response.join("\n")
break if color == :red
response.join("\n")
end
end

puts threads.map(&:value)
end
end
end
Expand Down
36 changes: 21 additions & 15 deletions lib/guac/commands/up.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,30 @@ def initialize(options)
end
end

def execute(input: $stdin, output: $stdout)
@repos.each do |repo|
output.puts "Updating #{repo.name.bold} on branch #{repo.branch.underline}".colorize(:blue)
response = []
def execute
threads = @repos.map do |repo|
puts "Updating #{repo.name.bold} on branch #{repo.branch.underline}".colorize(:blue)

begin
repo.checkout
response << repo.pull
rescue Guac::SysCommandError => e
output.puts e.message.colorize(:red)
break
end
Thread.new do
response = []

begin
repo.checkout
response << repo.pull
rescue Guac::SysCommandError => e
response << e.message.colorize(:red)
break
end

response.compact!
color, response = Colors.paint(response)
output.puts response.join("\n")
break if color == :red
response.compact!
response = Colors.paint(response)
response.unshift(repo.name.bold.colorize(:blue))
response.join("\n")
end
end

puts '========'
puts threads.map(&:value)
end
end
end
Expand Down

0 comments on commit 83a4981

Please sign in to comment.