Skip to content

Commit 7591b40

Browse files
committed
add set-version command
1 parent e7d3d6e commit 7591b40

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/main.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ enum Command {
4343
#[arg(value_name = "CRATE")]
4444
crate_name: String,
4545
},
46+
/// Force set a dependency to a version.
47+
///
48+
/// Can be used to override result of prepare release
49+
SetVersion {
50+
/// Crate name to print dependencies for.
51+
#[arg(value_name = "CRATE")]
52+
crate_name: String,
53+
54+
#[arg(value_name = "CRATE_VERSION")]
55+
crate_version: String,
56+
},
4657

4758
/// Build
4859
Build {
@@ -372,6 +383,25 @@ fn main() -> Result<()> {
372383
Command::Build { crate_name } => {
373384
build::build(&ctx, crate_name.as_deref())?;
374385
}
386+
Command::SetVersion {
387+
crate_name,
388+
crate_version,
389+
} => {
390+
let newver = crate_version;
391+
let name = &crate_name;
392+
let c = ctx.crates.get_mut(name).unwrap();
393+
let oldver = c.version.clone();
394+
update_version(c, &newver)?;
395+
396+
let c = ctx.crates.get(name).unwrap();
397+
// Update all nodes further down the tree
398+
update_graph_deps(&ctx, &ctx.graph, name, &oldver, &newver)?;
399+
update_graph_deps(&ctx, &ctx.build_graph, name, &oldver, &newver)?;
400+
update_graph_deps(&ctx, &ctx.dev_graph, name, &oldver, &newver)?;
401+
402+
// Update changelog
403+
update_changelog(&ctx.root, c)?;
404+
}
375405
Command::SemverCheck { crate_name } => {
376406
let c = ctx.crates.get(&crate_name).unwrap();
377407
if !c.publish {

0 commit comments

Comments
 (0)