Created
March 22, 2011 17:32
-
-
Save jamster/881641 to your computer and use it in GitHub Desktop.
quick script to parse git logs and turn them to a data structure
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
# Usage: | |
# git log | ruby git_commit_parser.rb | |
# https://gist.github.com/881641 | |
# By: Jason Amster | |
# [email protected] | |
require 'rubygems' | |
require 'pp' | |
logs = STDIN.read | |
logs = logs.split("commit ") | |
logs.shift | |
logs = logs.map do |log| | |
l = log.split("\n") | |
commit = l.shift | |
author = l.shift.to_s.split("Author: ")[1] | |
x = author.to_s.split(" ") | |
email = x.pop | |
name = x.join(' ') | |
date = l.shift.to_s.split("Date: ")[1].to_s.strip | |
comments = l.join("\n") | |
{ | |
:commit => commit, | |
:author => author, | |
:name => name, | |
:email => email, | |
:date => date, | |
:comments => comments | |
} | |
end | |
pp logs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment