class Honeybadger::Util::Revision

def detect(root = Dir.pwd)

def detect(root = Dir.pwd)
  revision = from_heroku ||
    from_capistrano(root) ||
    from_git
  revision = revision.to_s.strip
  return unless revision =~ /\S/
  revision
end

def from_capistrano(root)

def from_capistrano(root)
  file = File.join(root, 'REVISION')
  return nil unless File.file?(file)
  File.read(file) rescue nil
end

def from_git

def from_git
  return nil unless File.directory?('.git')
  `git rev-parse HEAD 2> #{File::NULL}` rescue nil
end

def from_heroku

See https://devcenter.heroku.com/articles/dyno-metadata

runtime-dyno-metadata`
Requires (currently) alpha platform feature `heroku labs:enable
def from_heroku
  ENV['HEROKU_SLUG_COMMIT']
end