Sha256: e92e1d1010ac9a741241edb6f20080c1782f24442fada783fe3d44cce7cbabd4

Contents?: true

Size: 552 Bytes

Versions: 142

Compression:

Stored size: 552 Bytes

Contents

# frozen_string_literal: true

class GitCommitSha
  def self.current
    new.current
  end

  def current
    sha = development_sha || capistrano_sha || heroku_sha
    sha.present? && sha[0...6]
  end

  private

  def development_sha
    Rails.env.development? && `git rev-parse HEAD`
  end

  def heroku_sha
    ENV.fetch("SOURCE_VERSION", "N/A")
  end

  def capistrano_sha
    sha_from_file("REVISION")
  end

  def sha_from_file(filename)
    file = Renalware::Engine.root.join(filename)
    File.exist?(file) && File.open(file, &:gets)
  end
end

Version data entries

142 entries across 142 versions & 1 rubygems

Version Path
renalware-core-2.1.1 lib/git_commit_sha.rb
renalware-core-2.1.0 lib/git_commit_sha.rb
renalware-core-2.0.167 lib/git_commit_sha.rb
renalware-core-2.0.166 lib/git_commit_sha.rb
renalware-core-2.0.165 lib/git_commit_sha.rb
renalware-core-2.0.164 lib/git_commit_sha.rb
renalware-core-2.0.163 lib/git_commit_sha.rb
renalware-core-2.0.162 lib/git_commit_sha.rb
renalware-core-2.0.161 lib/git_commit_sha.rb
renalware-core-2.0.160 lib/git_commit_sha.rb
renalware-core-2.0.159 lib/git_commit_sha.rb
renalware-core-2.0.158 lib/git_commit_sha.rb
renalware-core-2.0.157 lib/git_commit_sha.rb
renalware-core-2.0.156 lib/git_commit_sha.rb
renalware-core-2.0.155 lib/git_commit_sha.rb
renalware-core-2.0.153 lib/git_commit_sha.rb
renalware-core-2.0.152 lib/git_commit_sha.rb
renalware-core-2.0.151 lib/git_commit_sha.rb
renalware-core-2.0.149 lib/git_commit_sha.rb
renalware-core-2.0.148 lib/git_commit_sha.rb