Skip to content

Instantly share code, notes, and snippets.

@fredrikhenne
Forked from akahn/git_days.rb
Created March 6, 2011 18:24
Show Gist options
  • Save fredrikhenne/857490 to your computer and use it in GitHub Desktop.
Save fredrikhenne/857490 to your computer and use it in GitHub Desktop.
dir = ARGV.last || '.git'
git_cmd = "git --git-dir=#{dir} --no-pager log --no-merges --date-order --format=format:'%at %h %an %s'"
r, w = IO.pipe
spawn({}, git_cmd, :out => w)
def bold(text)
"\033[1m#{text}\033[0m"
end
def normalized(time)
time.strftime("%F")
end
trap(:INT) do
puts
exit
end
memo = Time.now + 86_400
r.each do |line|
begin
parts = line.split("\t")
time = Time.at(parts.shift.to_i)
if normalized(time) != normalized(memo)
puts
puts bold(time.strftime("%A, %B %e, %Y"))
memo = time
end
puts "* " + parts.join(" ")
rescue Errno::EPIPE
break
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment