From 22a96c149b23d82ab52d5380f3aa07cc795cccf5 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 12 Apr 2022 15:56:20 -0500 Subject: [PATCH] fix: Report special dry-run failure message Someone reported confusing behavior in a comment in #298 that turned out to be because dry-run failed and we had both missed that. Now, if dry-run fails, we'll report a clearer message about it. --- src/release.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/release.rs b/src/release.rs index 35e80aeb3..593cdfe0b 100644 --- a/src/release.rs +++ b/src/release.rs @@ -121,12 +121,14 @@ fn release_packages<'m>( pkgs: &'m [PackageRelease<'m>], ) -> Result { let dry_run = args.dry_run(); + let mut failed = false; // STEP 0: Help the user make the right decisions. git::git_version()?; if git::is_dirty(ws_meta.workspace_root.as_std_path())? { log::error!("Uncommitted changes detected, please commit before release."); + failed = true; if !dry_run { return Ok(101); } @@ -147,6 +149,7 @@ fn release_packages<'m>( } } if tag_exists { + failed = true; if !dry_run { return Ok(101); } @@ -168,6 +171,7 @@ fn release_packages<'m>( } } if downgrades_present { + failed = true; if !dry_run { return Ok(101); } @@ -196,6 +200,7 @@ fn release_packages<'m>( } } if double_publish { + failed = true; if !dry_run { return Ok(101); } @@ -266,6 +271,7 @@ fn release_packages<'m>( ws_config.allow_branch().join(", ") ); log::trace!("Due to {:?}", good_branch_match); + failed = true; if !dry_run { return Ok(101); } @@ -704,10 +710,16 @@ fn release_packages<'m>( } if dry_run { - log::warn!("Ran a `dry-run`, re-run with `--execute` if all looked good."); + if failed { + log::error!("Dry-run failed, resolve the above errors and try again."); + Ok(107) + } else { + log::warn!("Ran a `dry-run`, re-run with `--execute` if all looked good."); + Ok(0) + } + } else { + Ok(0) } - - Ok(0) } static NOW: once_cell::sync::Lazy = once_cell::sync::Lazy::new(|| {