diff --git a/Library/Homebrew/dev-cmd/pr-pull.rb b/Library/Homebrew/dev-cmd/pr-pull.rb index 9e90cedc79..9392b6ed36 100644 --- a/Library/Homebrew/dev-cmd/pr-pull.rb +++ b/Library/Homebrew/dev-cmd/pr-pull.rb @@ -118,7 +118,7 @@ module Homebrew Utils.safe_popen_read("git", "-C", tap.path, "merge-base", "origin/HEAD", current_branch_head).strip else - T.must(current_branch_head) + current_branch_head || odie("Failed to get current branch head") end odebug "Pull request merge-base: #{original_commit}" diff --git a/Library/Homebrew/utils/curl.rb b/Library/Homebrew/utils/curl.rb index 16bc7501f3..92b088e625 100644 --- a/Library/Homebrew/utils/curl.rb +++ b/Library/Homebrew/utils/curl.rb @@ -11,6 +11,8 @@ module Utils module Curl include SystemCommand::Mixin extend SystemCommand::Mixin + include Utils::Output::Mixin + extend Utils::Output::Mixin extend T::Helpers requires_ancestor { Kernel } @@ -55,12 +57,14 @@ module Utils @curl_executable ||= T.let(HOMEBREW_SHIMS_PATH/"shared/curl", T.nilable(T.any(Pathname, String))) end - sig { returns(T.nilable(String)) } + sig { returns(String) } def curl_path @curl_path ||= T.let( - Utils.popen_read(curl_executable, "--homebrew=print-path").chomp.presence, + Utils.popen_read(curl_executable, "--homebrew=print-path").chomp, T.nilable(String), ) + odie("Failed to get curl path") if @curl_path.blank? + @curl_path end sig { void } @@ -598,7 +602,13 @@ module Utils sig { returns(Version) } def curl_version @curl_version ||= T.let({}, T.nilable(T::Hash[String, Version])) - @curl_version[T.must(curl_path)] ||= Version.new(T.must(curl_output("-V").stdout[/curl (\d+(\.\d+)+)/, 1])) + curl_v_stdout = curl_output("-V").stdout + version = curl_v_stdout[/curl (\d+(?:\.\d+)+)/, 1] + if version + @curl_version[curl_path] ||= Version.new(version) + else + odie("Failed to parse curl version from #{curl_v_stdout}") + end end sig { returns(T::Boolean) }