-
-
Save fredrikhenne/857490 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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