Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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