Sha256: 9d9ebb7fbb9ac9e30a150391aa76c49e8d0d6274e95feb0571d37d298a09fd53

Contents?: true

Size: 521 Bytes

Versions: 35

Compression:

Stored size: 521 Bytes

Contents

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

35 entries across 35 versions & 1 rubygems

Version Path
renalware-core-2.0.16 lib/git_commit_sha.rb
renalware-core-2.0.15 lib/git_commit_sha.rb
renalware-core-2.0.14 lib/git_commit_sha.rb
renalware-core-2.0.13 lib/git_commit_sha.rb
renalware-core-2.0.12 lib/git_commit_sha.rb
renalware-core-2.0.11 lib/git_commit_sha.rb
renalware-core-2.0.9 lib/git_commit_sha.rb
renalware-core-2.0.8 lib/git_commit_sha.rb
renalware-core-2.0.7 lib/git_commit_sha.rb
renalware-core-2.0.5 lib/git_commit_sha.rb
renalware-core-2.0.4 lib/git_commit_sha.rb
renalware-core-2.0.3 lib/git_commit_sha.rb
renalware-core-2.0.2 lib/git_commit_sha.rb
renalware-core-2.0.1 lib/git_commit_sha.rb
renalware-core-2.0.0 lib/git_commit_sha.rb
renalware-core-2.0.0.pre.rc13 lib/git_commit_sha.rb
renalware-core-2.0.0.pre.rc11 lib/git_commit_sha.rb
renalware-core-2.0.0.pre.rc10 lib/git_commit_sha.rb
renalware-core-2.0.0.pre.rc9 lib/git_commit_sha.rb
renalware-core-2.0.0.pre.rc8 lib/git_commit_sha.rb