Fallback on 'version' in case git fails

This commit is contained in:
0x1eef 2024-06-22 01:16:30 -03:00
parent cfaff60c7b
commit 3c02acab4c

View file

@ -46,10 +46,16 @@ module Utils
end
##
# @note
# This method returns the website version in
# case git fails or is unavailable
# @return [String]
# Returns the most recent git commit hash
def commit
@commit ||= cmd("git", "rev-parse", "HEAD").stdout.strip
@commit ||= begin
r = cmd("git", "rev-parse", "HEAD")
r.success? ? r.stdout.strip : version
end
end
##