gouf
10/6/2014 - 9:40 AM

Ruby からgit コマンドを実行して情報を取得

Ruby からgit コマンドを実行して情報を取得

directory_path = '__my_git_repository_path__'
commit_id = '__commit_id__'
Dir.chdir(directory_path) do
  git_show = `git show #{commit_id}`
  p git_show.lines.select{ |line| line.start_with?('Date:') }.join.chomp
  # => "Date:   Sat Oct 4 02:00:04 2014 +0900"
end