From 51ca73a53b5538681ecc8a1ba81209bcdf863315 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sat, 12 Aug 2023 21:48:18 +0200 Subject: [PATCH] fix(git): make sure we always fail on exit code != 0 Signed-off-by: kjuulh --- crates/cuddle-please-misc/src/git_client.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/cuddle-please-misc/src/git_client.rs b/crates/cuddle-please-misc/src/git_client.rs index 9512944..06db4df 100644 --- a/crates/cuddle-please-misc/src/git_client.rs +++ b/crates/cuddle-please-misc/src/git_client.rs @@ -79,6 +79,13 @@ impl VcsClient { let stdout = std::str::from_utf8(&checkout_branch.stdout)?; let stderr = std::str::from_utf8(&checkout_branch.stderr)?; tracing::debug!(stdout = stdout, stderr = stderr, "git {}", args.join(" ")); + let exit_code = checkout_branch.status; + if !exit_code.success() { + anyhow::bail!( + "failed to run git command: {}", + exit_code.code().unwrap_or(-1) + ) + } } }