From f523dcf9df17329038fa0fcd550c6c029a8e5ba4 Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Tue, 18 Apr 2023 10:58:57 +0200 Subject: [PATCH] REFACTOR: Simplify git command execution --- lib/discourse.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/discourse.rb b/lib/discourse.rb index 1c7b1a31abe..e7e2df83e20 100644 --- a/lib/discourse.rb +++ b/lib/discourse.rb @@ -801,17 +801,11 @@ module Discourse end def self.try_git(git_cmd, default_value) - version_value = false - begin - version_value = `#{git_cmd}`.strip + `#{git_cmd}`.strip rescue StandardError - version_value = default_value - end - - version_value = default_value if version_value.empty? - - version_value + default_value + end.presence || default_value end # Either returns the site_contact_username user or the first admin.