Commit hash version but not in git

Fixes #11
This commit is contained in:
Adam
2023-02-05 20:31:14 +01:00
parent 9aa57dd0c7
commit 2fe01f13df
2 changed files with 19 additions and 1 deletions

View File

@@ -91,7 +91,15 @@ class Mrsk::Commander
private
def cascading_version
version.presence || ENV["VERSION"] || `git rev-parse HEAD`.strip
version.presence || ENV["VERSION"] || current_commit_hash
end
def current_commit_hash
if system("git rev-parse")
`git rev-parse HEAD`.strip
else
raise "Can't use commit hash as version, no git repository found in #{Dir.pwd}"
end
end
# Lazy setup of SSHKit