Sha256: 920d76f66a27ad5612c524c826dbba7548e62e0be3af4ebd11551ca0f24070b7

Contents?: true

Size: 936 Bytes

Versions: 44

Compression:

Stored size: 936 Bytes

Contents

module Honeybadger
  module Util
    class Revision
      class << self
        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

        # Requires (currently) alpha platform feature `heroku labs:enable
        # runtime-dyno-metadata`
        #
        # See https://devcenter.heroku.com/articles/dyno-metadata
        def from_heroku
          ENV['HEROKU_SLUG_COMMIT']
        end

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

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

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
honeybadger-5.24.0 lib/honeybadger/util/revision.rb
honeybadger-5.23.0 lib/honeybadger/util/revision.rb
honeybadger-5.22.0 lib/honeybadger/util/revision.rb
honeybadger-5.21.0 lib/honeybadger/util/revision.rb
honeybadger-5.20.1 lib/honeybadger/util/revision.rb
honeybadger-5.20.0 lib/honeybadger/util/revision.rb
honeybadger-5.19.2 lib/honeybadger/util/revision.rb
honeybadger-5.19.1 lib/honeybadger/util/revision.rb
honeybadger-5.19.0 lib/honeybadger/util/revision.rb
honeybadger-5.18.0 lib/honeybadger/util/revision.rb
honeybadger-5.17.0 lib/honeybadger/util/revision.rb
honeybadger-5.16.0 lib/honeybadger/util/revision.rb
honeybadger-5.15.6 lib/honeybadger/util/revision.rb
honeybadger-5.15.5 lib/honeybadger/util/revision.rb
honeybadger-5.15.4 lib/honeybadger/util/revision.rb
honeybadger-5.15.3 lib/honeybadger/util/revision.rb
honeybadger-5.15.2 lib/honeybadger/util/revision.rb
honeybadger-5.15.1 lib/honeybadger/util/revision.rb
honeybadger-5.15.0 lib/honeybadger/util/revision.rb
honeybadger-5.14.2 lib/honeybadger/util/revision.rb