Support passing a short-sha version for rollback when using git.

Only for emergencies.
This commit is contained in:
Matthew Kent
2023-11-21 15:44:59 -08:00
parent 635876bdb9
commit 5b694a0814
2 changed files with 11 additions and 1 deletions

View File

@@ -93,7 +93,7 @@ class Kamal::Cli::Main < Kamal::Cli::Base
mutating do
invoke_options = deploy_options
KAMAL.config.version = version
KAMAL.config.version = Kamal::Git.used? ? Kamal::Git.resolve_revision(version) : version
old_version = nil
if container_available?(version)

View File

@@ -13,6 +13,16 @@ module Kamal::Git
`git rev-parse HEAD`.strip
end
# Attempt to convert a short -> long git sha, or return the original
def resolve_revision(revision)
resolved_rev = `git rev-parse -q --verify #{revision}`.strip
if resolved_rev.empty?
revision
else
resolved_rev
end
end
def uncommitted_changes
`git status --porcelain`.strip
end