Skip to content

Instantly share code, notes, and snippets.

@babatakao
Created December 7, 2012 05:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save babatakao/4231086 to your computer and use it in GitHub Desktop.
Save babatakao/4231086 to your computer and use it in GitHub Desktop.
git logを一覧便利なTSVで表示
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")
@morimorihoge
Copy link

$ git log --pretty=format:"hogehoge"
を使っても良い気が.でもまあ,rubyで処理した方が柔軟かな?

@babatakao
Copy link
Author

確かにこの程度ならformatで十分でした><
~/.gitconfigに以下を書いて解決。
[alias]
logpt = log --pretty=format:"%H %ad %an %s"

@babatakao
Copy link
Author

メモ:フォーマットはここに書いてある

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment