Created
December 7, 2012 05:56
-
-
Save babatakao/4231086 to your computer and use it in GitHub Desktop.
git logを一覧便利なTSVで表示
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
require 'date' | |
logs = {} | |
hash = nil | |
`git log`.each_line do |line| | |
if line =~ /^commit (\w+)/ | |
hash = $1 | |
end | |
logs[hash] ||= {} | |
if line =~ /^Author: ([^<]*)/ | |
logs[hash][:author] = $1 | |
end | |
if line =~ /^Date: (.*)/ | |
logs[hash][:date] = DateTime.parse($1) | |
end | |
if line =~ /^ (.*)/ | |
logs[hash][:comment] ||= $1.chomp | |
end | |
end | |
puts logs.map{|hash, data| "#{hash}\t#{data[:date]}\t#{data[:author]}\t#{data[:comment]}"}.join("\n") |
確かにこの程度ならformatで十分でした><
~/.gitconfigに以下を書いて解決。
[alias]
logpt = log --pretty=format:"%H %ad %an %s"
メモ:フォーマットはここに書いてある
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ git log --pretty=format:"hogehoge"
を使っても良い気が.でもまあ,rubyで処理した方が柔軟かな?