How to display commit content in ruby

268 Views Asked by At

How do you display the commit content specified with SHA-1 in a Ruby on Rails application?

3

There are 3 best solutions below

1
sscirrus On

As a disclaimer I'm not sure if this is an answer to your question but I'll give you what I know:

In the console (folder for your project, obviously), you can get a list of the files you have changed and their status for your upcoming commit with:

git status

To get a readout of the exact code changes, you can type into the console:

gitk

Hope that helps!

0
Eric R. On

There's a good library for this. Include it in your gemfile and look at the docs for how to implement.

https://github.com/schacon/ruby-git

0
Pablo Fernandez heelhook On

Just use grit:

require 'grit'

repo = Grit::Repo.new(path_to_repo)
repo.commit(sha)

Then just play with the commit object returned. Check out http://grit.rubyforge.com/. If you want to see the changed files by that commit you can do

commit.diffs.each {|d| puts d.a_path || d.b_path }