Show elapsed time
This commit is contained in:
parent
0330206e55
commit
d96141f57d
@ -32,12 +32,15 @@ module Svi
|
||||
last_checkout_message = ""
|
||||
end
|
||||
end
|
||||
start_time = Time.new
|
||||
SvnRunner.run_svn("checkout", [url] + checkout_directory, allow_interactive: true) do |line|
|
||||
if line =~ /^A.{4}(.*)$/
|
||||
path = $1
|
||||
checked_out_paths << path
|
||||
clear_message[]
|
||||
last_checkout_message = "Checking out #{path}..."
|
||||
elapsed_time = Time.new - start_time
|
||||
elapsed_time_formatted = Util.format_time(elapsed_time)
|
||||
last_checkout_message = "Checking out #{path} [#{elapsed_time_formatted}]..."
|
||||
$stdout.write(last_checkout_message)
|
||||
$stdout.flush
|
||||
elsif line =~ /^\sU\s{3}/
|
||||
@ -54,7 +57,9 @@ module Svi
|
||||
n_files += 1
|
||||
end
|
||||
end
|
||||
$stdout.puts "Checked out revision #{revision}: #{n_files} file#{n_files == 1 ? '' : 's'}, #{n_directories} director#{n_directories == 1 ? 'y' : 'ies'}"
|
||||
elapsed_time = Time.new - start_time
|
||||
elapsed_time_formatted = Util.format_time(elapsed_time)
|
||||
$stdout.puts "Checked out revision #{revision}: #{n_files} file#{n_files == 1 ? '' : 's'}, #{n_directories} director#{n_directories == 1 ? 'y' : 'ies'} [#{elapsed_time_formatted}]"
|
||||
else
|
||||
clear_message[]
|
||||
$stdout.puts line
|
||||
|
@ -9,6 +9,33 @@ module Svi
|
||||
end
|
||||
end
|
||||
|
||||
def format_time(time)
|
||||
if time < 10
|
||||
sprintf("%.3fs", time)
|
||||
else
|
||||
days = (time / (60 * 60 * 24)).to_i
|
||||
time -= days * (60 * 60 * 24)
|
||||
hours = (time / (60 * 60)).to_i
|
||||
time -= hours * (60 * 60)
|
||||
minutes = (time / 60).to_i
|
||||
time -= minutes * 60
|
||||
incl = false
|
||||
formatted = ""
|
||||
if days != 0
|
||||
incl = true
|
||||
formatted += "#{days}d"
|
||||
end
|
||||
if hours != 0 or incl
|
||||
incl = true
|
||||
formatted += "#{hours}h"
|
||||
end
|
||||
if minutes != 0 or incl
|
||||
formatted += "#{minutes}m"
|
||||
end
|
||||
formatted += "#{time.round}s"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user