Sha256: 8bbc365fb74e50f9ba323beb15818392b6e182604c31768c61d2aef3caa5594d

Contents?: true

Size: 834 Bytes

Versions: 6

Compression:

Stored size: 834 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 2> #{File::NULL}`.strip rescue nil
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
honeybadger-4.12.1 lib/honeybadger/util/revision.rb
honeybadger-4.12.0 lib/honeybadger/util/revision.rb
honeybadger-4.11.0 lib/honeybadger/util/revision.rb
honeybadger-4.10.0 lib/honeybadger/util/revision.rb
honeybadger-4.9.0 lib/honeybadger/util/revision.rb
honeybadger-4.8.0 lib/honeybadger/util/revision.rb