From e56c44a5f056b767a34d97ddfcc56d82858d8fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Tue, 14 Mar 2023 19:17:59 +0100 Subject: [PATCH] Fix swallowing original error message in `git_retry` (#573) --- spec/integration/install_spec.cr | 8 ++++++++ src/resolvers/git.cr | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/spec/integration/install_spec.cr b/spec/integration/install_spec.cr index 7ac0cb56..8b865022 100644 --- a/spec/integration/install_spec.cr +++ b/spec/integration/install_spec.cr @@ -1266,4 +1266,12 @@ describe "install" do end end end + + it "fails when git is missing" do + metadata = {dependencies: {web: "*"}} + with_shard(metadata) do + ex = expect_raises(FailedCommand) { run "shards install --no-color", env: {"PATH" => File.expand_path("../../bin", __DIR__), "SHARDS_CACHE_PATH" => ""} } + ex.stdout.should contain "Error missing git command line tool. Please install Git first!" + end + end end diff --git a/src/resolvers/git.cr b/src/resolvers/git.cr index f150ca36..b5559ca3 100644 --- a/src/resolvers/git.cr +++ b/src/resolvers/git.cr @@ -332,10 +332,11 @@ module Shards loop do yield break - rescue Error + rescue inner_err : Error retries += 1 next if retries < 3 - raise Error.new(err) + Log.debug { inner_err } + raise Error.new("#{err}: #{inner_err}") end end