Showing the git commit SHA that is currently deployed

I cannot count how many times I (or others) have asked the following question:

What is the difference between master and the production version?

We deploy about 3-5 times a day and we merge code about twice as much into master (some days, even more then that).

We deploy to servers with Capistrano, Capistrano has a very useful feature to write a REVISION file to the root of the project, this file contains a single line with the commit sha.

So, I thought I might set up a controller that will read this file and display it when I want.

So, I spec’d it out:

describe :git_sha do
  it "should read the file correctly" do
    File.should_receive(:open).with("#{Rails.root}/REVISION").and_return(stub(read: "aaa"))
    get :git_sha
    response.body.should == "aaa"

And this is the controller code:

def git_sha
  revision ="#{Rails.root}/REVISION").read.strip.to_s
  render :text => revision
Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at