Private Gist
All pages are served over SSL and all pushing and pulling is done over SSH. No one may fork, clone, or view it unless they are given this private URL.
Every gist with this icon (
) is private.
Public Gist
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def format_time_interval(from_time, to_time)
seconds = (to_time - from_time).abs.round
minutes, seconds = seconds.divmod(60)
if minutes > 60 * 24
" "
elsif minutes > 60
hours, minutes =
" %2dh %2dm " % minutes.divmod(60)
else
" %2dm %2ds " % [minutes, seconds]
end
end
desc "Print the commits with the amount of time between each commit"
task :time do
if `git config --list` =~ /^user\.email=(.*)$/
email = $1
else
raise "Could not find your email address in git config"
end
prev_time = Time.now
prev_subject = nil
`git log --author=#{email} --pretty=format:"%ct %s"`.each_line do |l|
if l =~ /^(\d+) (.*)$/
curr_time = Time.at($1.to_i)
if prev_subject
puts "#{prev_time.strftime('%a, %b %d %I:%M%p')} #{format_time_interval(prev_time, curr_time)} #{prev_subject}"
end
prev_subject = $2
prev_time = curr_time
end
end
end
Please log in to comment.







