[image]
pjb3 (owner)

Revisions

4b1830 pjb3 July 07, 2009 8d4767 pjb3 July 06, 2009
gist: 141886 Download_button fork
public
public
Public Clone URL: git://gist.github.com/141886.git
Give this clone URL to anyone.
git clone git://gist.github.com/141886.git gist-141886
Embed All Files: show embed
time.rake #
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.


You are viewing a mobilized version of this site...
View original page here

Mobilized by Mowser Mowser