Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Report special dry-run failure message #453

Merged
merged 1 commit into from
Apr 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,14 @@ fn release_packages<'m>(
pkgs: &'m [PackageRelease<'m>],
) -> Result<i32, error::FatalError> {
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);
}
Expand All @@ -147,6 +149,7 @@ fn release_packages<'m>(
}
}
if tag_exists {
failed = true;
if !dry_run {
return Ok(101);
}
Expand All @@ -168,6 +171,7 @@ fn release_packages<'m>(
}
}
if downgrades_present {
failed = true;
if !dry_run {
return Ok(101);
}
Expand Down Expand Up @@ -196,6 +200,7 @@ fn release_packages<'m>(
}
}
if double_publish {
failed = true;
if !dry_run {
return Ok(101);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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<String> = once_cell::sync::Lazy::new(|| {
Expand Down