From 3c02acab4ca65fd7800068283d405703496799b3 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Sat, 22 Jun 2024 01:16:30 -0300 Subject: [PATCH] Fallback on 'version' in case git fails --- nanoc/lib/utils.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nanoc/lib/utils.rb b/nanoc/lib/utils.rb index 678d7cb..594ba17 100644 --- a/nanoc/lib/utils.rb +++ b/nanoc/lib/utils.rb @@ -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 ##