class Honeybadger::Util::Revision

Public Class Methods

detect(root = Dir.pwd) click to toggle source
# File lib/honeybadger/util/revision.rb, line 5
def detect(root = Dir.pwd)
  revision = from_heroku ||
    from_capistrano(root) ||
    from_git

  revision = revision.to_s.strip
  return unless revision =~ /\S/

  revision
end

Private Class Methods

from_capistrano(root) click to toggle source
# File lib/honeybadger/util/revision.rb, line 26
def from_capistrano(root)
  file = File.join(root, 'REVISION')
  return nil unless File.file?(file)
  File.read(file) rescue nil
end
from_git() click to toggle source
# File lib/honeybadger/util/revision.rb, line 32
def from_git
  return nil unless File.directory?('.git')
  `git rev-parse HEAD 2> #{File::NULL}` rescue nil
end
from_heroku() click to toggle source

Requires (currently) alpha platform feature ‘heroku labs:enable runtime-dyno-metadata`

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

# File lib/honeybadger/util/revision.rb, line 22
def from_heroku
  ENV['HEROKU_SLUG_COMMIT']
end