Sha256: 22e51c65adda5fd666ee1e5ab57d18f8f5bc249905367fbf674b165795e74886

Contents?: true

Size: 817 Bytes

Versions: 25

Compression:

Stored size: 817 Bytes

Contents

module Honeybadger
  module Util
    class Revision
      class << self
        def detect(root = Dir.pwd)
          from_heroku ||
            from_capistrano(root) ||
            from_git
        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).strip rescue nil
        end

        def from_git
          return nil unless File.directory?('.git')
          `git rev-parse HEAD`.strip rescue nil
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
honeybadger-4.7.3 lib/honeybadger/util/revision.rb
honeybadger-4.7.2 lib/honeybadger/util/revision.rb
honeybadger-4.7.1 lib/honeybadger/util/revision.rb
honeybadger-4.7.0 lib/honeybadger/util/revision.rb
honeybadger-4.6.0 lib/honeybadger/util/revision.rb
honeybadger-4.5.6 lib/honeybadger/util/revision.rb
honeybadger-4.5.5 lib/honeybadger/util/revision.rb
honeybadger-4.5.4 lib/honeybadger/util/revision.rb
honeybadger-4.5.3 lib/honeybadger/util/revision.rb
honeybadger-4.5.2 lib/honeybadger/util/revision.rb
honeybadger-4.5.1 lib/honeybadger/util/revision.rb
honeybadger-4.5.0 lib/honeybadger/util/revision.rb
honeybadger-4.4.2 lib/honeybadger/util/revision.rb
honeybadger-4.4.1 lib/honeybadger/util/revision.rb
honeybadger-4.4.0 lib/honeybadger/util/revision.rb
honeybadger-4.3.1 lib/honeybadger/util/revision.rb
honeybadger-4.3.0 lib/honeybadger/util/revision.rb
honeybadger-4.2.2 lib/honeybadger/util/revision.rb
honeybadger-4.2.1 lib/honeybadger/util/revision.rb
honeybadger-4.2.0 lib/honeybadger/util/revision.rb