Sha256: 4cbf62815de7b4db6fec652c9af92b8e194809d1da303c2e5058d98a3b52a5e9

Contents?: true

Size: 745 Bytes

Versions: 2

Compression:

Stored size: 745 Bytes

Contents

module PlainApm
  class DeployTracking
    class << self
      def revision
        git_revision || hg_revision || heroku_revision
      end

      private

      def git_revision
        return unless File.exist?(".git")
        rev = `git rev-parse --short=8 HEAD`.strip
        rev if !rev.empty?
      rescue Error::ENOENT # No git installed
        nil
      end

      def heroku_revision
        rev = ENV.fetch("GIT_REV", ENV.fetch("HEROKU_SLUG_COMMIT", ""))[0...8]
        rev if !rev.empty?
      end

      def hg_revision
        return unless File.exist?(".hg")
        rev = `hg log -l 1 -r . -T '{node}'`.strip
        rev if !rev.empty?
      rescue Error::ENOENT # No mercurial installed
        nil
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
plain_apm-0.10.2 lib/plain_apm/deploy_tracking.rb
plain_apm-0.10.0 lib/plain_apm/deploy_tracking.rb