use governor_application::release::{BumpInput, bump};
use crate::cli::{BumpOpts, OutputFormat};
use crate::error::{CommandExitCode, Result};
use crate::presenter::print_json;
use crate::runtime::{cargo_adapter, git_adapter};
pub async fn execute(
workspace_path: &str,
opts: BumpOpts,
_format: OutputFormat,
dry_run: bool,
) -> Result<CommandExitCode> {
let started_at = std::time::Instant::now();
let cargo = cargo_adapter();
let git = git_adapter(workspace_path)?;
let output = bump(
&cargo,
&git,
BumpInput {
workspace_path: workspace_path.to_string(),
version: opts.version,
bump: opts.bump,
no_changelog: opts.no_changelog,
no_commit: opts.no_commit,
no_tag: opts.no_tag,
commit_template: opts.commit_template,
tag_template: opts.tag_template,
dry_run,
allow_version_drift: opts.allow_version_drift,
allow_dirty: opts.allow_dirty,
},
)
.await?;
let workspace = output.workspace.clone();
let success = output.changed || output.dry_run;
print_json(
"release.bump",
Some(workspace),
success,
output.clone(),
started_at,
Vec::new(),
)?;
Ok(if output.changed || output.dry_run {
CommandExitCode::Success
} else {
CommandExitCode::NoChanges
})
}