Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@benhoskings
Created September 1, 2011 00:04
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benhoskings/1185085 to your computer and use it in GitHub Desktop.
Save benhoskings/1185085 to your computer and use it in GitHub Desktop.
A git ref in every response!
class ApplicationController < ActionController::Base
before_filter {
headers['X-Refspec'] = TC::Services.refspec
}
end
module TC
class Services
# The git ref that's currently running. Using ||= in a class method
# means we only shell out once, when the instance is booted.
def self.refspec
@_refspec ||= `git rev-parse --short HEAD 2>/dev/null`.strip
end
# ...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment