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