2008年 03月 20日

git

現在のワーキングツリーの .git ディレクトリの位置

$ cd ~/tmp/git/Documentation
$ git rev-parse --git-dir
/Users/cho45/tmp/git/.git

完全なコミットログ (プログラム解析するための)

$ git log --no-color -z --pretty=raw --parents
require "digest/sha1"

def git_log(data, add)
	boundary = "__#{Digest::SHA1.hexdigest(rand.to_s)}__"
	p boundary
	format = data.map {|f| "%#{f}" }.join(boundary)

	`git log --no-color -z --pretty=format:'#{format}' --parents #{add}`.split(/\0/).map {|c|
		yield c.split(boundary)
	}
end

git_log(%w(H T P an ae ai s b), "HEAD~10..") do |commit|
	commit_hash, tree_hash, parents, author_name, author_mail, author_date, subject, body = commit
	p subject
	p body
end

github (Rails っぽい?) の中の人が ruby binding かいてるみたいだ。https://rubyforge.org/projects/grit/ mojombo++ (よくしらない