Require git to exit successfully in Utils#commit
This commit is contained in:
parent
9b3822bf1e
commit
a7e413310c
1 changed files with 11 additions and 5 deletions
|
@ -12,6 +12,10 @@ module Utils
|
|||
require_relative "utils/erb"
|
||||
require_relative "utils/opengraph"
|
||||
|
||||
##
|
||||
# Generic error
|
||||
Error = Class.new(RuntimeError) unless defined?(Error)
|
||||
|
||||
##
|
||||
# @return [Ryo::Object]
|
||||
# Returns common directory paths as a Ryo object
|
||||
|
@ -46,15 +50,17 @@ module Utils
|
|||
end
|
||||
|
||||
##
|
||||
# @note
|
||||
# This method returns the website version in
|
||||
# case git fails or is unavailable
|
||||
# @raise [Utils::Error]
|
||||
# When git fails or is unavailable
|
||||
# @return [String]
|
||||
# Returns the most recent git commit hash
|
||||
def commit
|
||||
@commit ||= begin
|
||||
r = cmd("git", "rev-parse", "HEAD")
|
||||
r.success? ? r.stdout.strip : version
|
||||
hash = nil
|
||||
cmd("git", "rev-parse", "HEAD")
|
||||
.success { hash = _1.stdout.strip }
|
||||
.failure { raise(Error, "git exited unsuccessfully in method Utils#commit", []) }
|
||||
hash
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue