Skip to content

Instantly share code, notes, and snippets.

@alexschwartz
Last active March 30, 2016 22:38
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 alexschwartz/55448e4d256f2e71ca326b2327e4e941 to your computer and use it in GitHub Desktop.
Save alexschwartz/55448e4d256f2e71ca326b2327e4e941 to your computer and use it in GitHub Desktop.
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