Skip to content
New issue

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

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

Already on GitHub? # to your account

Add --release-type flag #361

Merged
merged 7 commits into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
15 changes: 11 additions & 4 deletions src/check_release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,31 @@ pub(super) fn run_check_release(
crate_name: &str,
current_crate: VersionedCrate,
baseline_crate: VersionedCrate,
assume_semver: Option<ActualSemverUpdate>,
) -> anyhow::Result<bool> {
let current_version = current_crate.crate_version();
let baseline_version = baseline_crate.crate_version();

let version_change = classify_semver_version_change(current_version, baseline_version)
.unwrap_or_else(|| {
let version_change = assume_semver.unwrap_or_else(|| {
classify_semver_version_change(current_version, baseline_version).unwrap_or_else(|| {
config
.shell_warn(
"Could not determine whether crate version changed. Assuming no change.",
)
.expect("print failed");
ActualSemverUpdate::NotChanged
});
})
});
let change = match version_change {
ActualSemverUpdate::Major => "major",
ActualSemverUpdate::Minor => "minor",
ActualSemverUpdate::Patch => "patch",
ActualSemverUpdate::NotChanged => "no",
};
let assume = match assume_semver {
Some(_) => "assume ",
None => "",
};

let queries = SemverQuery::all_queries();

Expand All @@ -119,9 +125,10 @@ pub(super) fn run_check_release(
config.shell_status(
"Checking",
format_args!(
"{crate_name} v{} -> v{} ({} change)",
"{crate_name} v{} -> v{} ({}{} change)",
baseline_version.unwrap_or("unknown"),
current_version.unwrap_or("unknown"),
assume,
change
),
)?;
Expand Down
24 changes: 22 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ use std::path::PathBuf;
use clap::{Args, Parser, Subcommand};
use trustfall_rustdoc::{load_rustdoc, VersionedCrate};

use crate::{check_release::run_check_release, config::GlobalConfig, util::slugify};
use crate::{
check_release::run_check_release, config::GlobalConfig, query::ActualSemverUpdate,
util::slugify,
};

fn main() -> anyhow::Result<()> {
human_panic::setup_panic!();
Expand Down Expand Up @@ -143,7 +146,13 @@ fn main() -> anyhow::Result<()> {
baseline_highest_allowed_version,
)?;

let success = run_check_release(&mut config, name, current_crate, baseline_crate)?;
let success = run_check_release(
&mut config,
name,
current_crate,
baseline_crate,
args.assume_semver,
)?;
vec![Ok(success)]
} else {
let metadata = args.manifest.metadata().exec()?;
Expand Down Expand Up @@ -184,6 +193,7 @@ fn main() -> anyhow::Result<()> {
crate_name,
current_crate,
baseline_crate,
args.assume_semver,
)?)
}
})
Expand Down Expand Up @@ -334,6 +344,16 @@ struct CheckRelease {
)]
baseline_rustdoc: Option<PathBuf>,

/// Assume given semver type and ignore the actual version difference.
Finomnis marked this conversation as resolved.
Show resolved Hide resolved
#[arg(
value_enum,
long,
value_name = "TYPE",
help_heading = "Overrides",
group = "overrides"
)]
assume_semver: Option<ActualSemverUpdate>,

#[command(flatten)]
verbosity: clap_verbosity_flag::Verbosity<clap_verbosity_flag::InfoLevel>,
}
Expand Down
2 changes: 1 addition & 1 deletion src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl RequiredSemverUpdate {
}
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, clap::ValueEnum)]
Finomnis marked this conversation as resolved.
Show resolved Hide resolved
pub(crate) enum ActualSemverUpdate {
Major,
Minor,
Expand Down