Last active
March 30, 2016 22:38
-
-
Save alexschwartz/55448e4d256f2e71ca326b2327e4e941 to your computer and use it in GitHub Desktop.
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 'git' | |
require 'json' | |
filename = 'data.json' | |
working_dir = 'resources/repo1/' | |
g = Git.open(working_dir) #, :log => Logger.new(STDOUT)) | |
history = [] | |
g.log.path(filename).each do |log_entry| | |
history << { | |
:sha => log_entry.sha, | |
:author => log_entry.author.name, | |
:date => log_entry.date.strftime("%Y-%m-%d %H:%M"), | |
:message => log_entry.message, | |
:data => JSON.parse(g.object("#{log_entry.sha}:#{filename}").contents) | |
} | |
end | |
puts JSON.pretty_generate(history) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment