Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed Git Commit Log in Rails App?

So, I have a 'development blog' in a rails app I'm working on right now. I'm using Git for version control and deployment (although right now I'm the only person working on it).

Now, when I make changes in Git I put a pretty decent log entry about what I've done. I'd love to have the Git commit log automatically posted to the development blog -- or otherwise available for others to read within the deployed site.

Is there an automated way to pull the Git Commit Log into a view in a rails app?

like image 743
Andrew Avatar asked Jan 05 '11 02:01

Andrew


2 Answers

Some Git hosts will allow you to provide a post commit hook, and this can enable you to make an HTTP call to send the relevant log statements to your app.

If you're self-hosting, check out githooks.

If you're using Github, you can use their post-commit post (more details here: http://help.github.com/post-receive-hooks/)

like image 171
Ben Scheirman Avatar answered Oct 12 '22 05:10

Ben Scheirman


You may want to look into grit which is a ruby library that gives access to stuff in a git repo.

I'm using grit in my personal blog. I write articles in text files and commit them to a git repo, then push the git repo to my server where my rails app reads files from git repo as blog posts using grit.

For example, here's how easy it is to get the last commit message:

require 'grit'
include Grit
repo = Repo.new('<path to your .git dir>')
puts repo.commits('master',1)[0].message # latest commit message
puts repo.commits('master',1)[0].date # last commit date
like image 31
Upgradingdave Avatar answered Oct 12 '22 03:10

Upgradingdave