1

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

jdl
  • 17,702
  • 4
  • 51
  • 54
Kazimír
  • 31
  • 2

3 Answers3

4

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

Eric R.
  • 933
  • 1
  • 9
  • 19
0

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!

sscirrus
  • 55,407
  • 41
  • 135
  • 228
  • thanks fot gitk it seems well, but this I wanted.I am writing code in ruby on rails and I need to display content of some revision, for example I have file aaa.txt with content 123, I'll commit it, then I'll do a revision of file aaa.txt, new content will be 123456, i commit it, Now I need to write code in ruby using for example grit to show conntent of some commit when from view I'll get sha of this commit, when I'll get sha of first commit I have to show content "123" – Kazimír Nov 19 '11 at 20:20
0

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 }
Pablo Fernandez heelhook
  • 11,985
  • 3
  • 21
  • 20