Extract Kamal::Git as gateway for all git usage

This commit is contained in:
dhh
2023-09-16 11:30:29 -07:00
parent 12a82a6c58
commit cfbfb37e23
8 changed files with 38 additions and 22 deletions

View File

@@ -278,10 +278,8 @@ class Kamal::Configuration
def git_version
@git_version ||=
if system("git rev-parse")
uncommitted_suffix = Kamal::Utils.uncommitted_changes.present? ? "_uncommitted_#{SecureRandom.hex(8)}" : ""
"#{`git rev-parse HEAD`.strip}#{uncommitted_suffix}"
if Kamal::Git.used?
[ Kamal::Git.revision, Kamal::Git.uncommitted_changes.present? ? "_uncommitted_#{SecureRandom.hex(8)}" : "" ].join
else
raise "Can't use commit hash as version, no git repository found in #{Dir.pwd}"
end