mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 14:31:25 +00:00
Rescues Errno::ENOENT when git is not installed, falling back to BUILD_COMMIT_SHA env var or "unknown". Fixes crash in Docker development containers that lack git.
23 lines
397 B
Ruby
23 lines
397 B
Ruby
module Sure
|
|
class << self
|
|
def version
|
|
Semver.new(semver)
|
|
end
|
|
|
|
def commit_sha
|
|
if Rails.env.production?
|
|
ENV["BUILD_COMMIT_SHA"]
|
|
else
|
|
ENV["BUILD_COMMIT_SHA"] || `git rev-parse HEAD`.chomp
|
|
end
|
|
rescue Errno::ENOENT
|
|
ENV.fetch("BUILD_COMMIT_SHA", "unknown")
|
|
end
|
|
|
|
private
|
|
def semver
|
|
"0.6.8-alpha.2"
|
|
end
|
|
end
|
|
end
|