Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku: Display Git Revision Hash and Timestamp in Views?

Let's say I have a Rails application deployed on Heroku. How can I display these pieces of information in my views?

  • The Git hash for the last revision
  • The Timestamp for the last revision
like image 673
Rich Apodaca Avatar asked Oct 17 '09 17:10

Rich Apodaca


2 Answers

Heroku sets an environment variable with the commit hash ENV['COMMIT_HASH'].

As for the timestamp, you could hit the github api with the hash if you host your code there. Looks like the ruby-github gem can help you with this, or you could do it yourself with HTTParty.

like image 78
Blake Taylor Avatar answered Oct 19 '22 18:10

Blake Taylor


The reason for this is because when your app is deployed onto the dyno grid to serve requests, it's compiled into a "slug" for fast deployment, and this slug doesn't have the git repo with it anymore.

like image 32
tfe Avatar answered Oct 19 '22 19:10

tfe