Skip to content

Commit

Permalink
boulder/cli/recipe: Allow suppression of recipe bump in updates
Browse files Browse the repository at this point in the history
This is hella useful if you're ammending a PR where you forgot
to alter the source, or need to refresh an existing PR when a new
version came out.

Signed-off-by: Ikey Doherty <[email protected]>
  • Loading branch information
ikeycode committed Dec 5, 2024
1 parent 4577074 commit 47f9149
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions boulder/src/cli/recipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ pub enum Subcommand {
help = "Overwrite the recipe file in place instead of printing to standard output"
)]
overwrite: bool,
#[arg(long, default_value = "false", help = "Don't increment the release number")]
no_bump: bool,
},
#[command(about = "Print macro definitions")]
Macros {
Expand Down Expand Up @@ -116,7 +118,8 @@ pub fn handle(command: Command, env: Env) -> Result<(), Error> {
overwrite,
version,
upstreams,
} => update(recipe, overwrite, version, upstreams),
no_bump,
} => update(recipe, overwrite, version, upstreams, no_bump),
Subcommand::Macros { _macro } => macros(_macro, env),
}
}
Expand Down Expand Up @@ -163,7 +166,13 @@ fn new(output: PathBuf, upstreams: Vec<Url>) -> Result<(), Error> {
Ok(())
}

fn update(recipe: Option<PathBuf>, overwrite: bool, version: String, upstreams: Vec<Upstream>) -> Result<(), Error> {
fn update(
recipe: Option<PathBuf>,
overwrite: bool,
version: String,
upstreams: Vec<Upstream>,
no_bump: bool,
) -> Result<(), Error> {
if overwrite && recipe.is_none() {
return Err(Error::OverwriteRecipeRequired);
}
Expand Down Expand Up @@ -191,7 +200,10 @@ fn update(recipe: Option<PathBuf>, overwrite: bool, version: String, upstreams:
GitUpstream(usize, serde_yaml::Value, String),
}

let mut updates = vec![Update::Version(version), Update::Release(parsed.source.release + 1)];
let mut updates = vec![Update::Version(version)];
if !no_bump {
updates.push(Update::Release(parsed.source.release + 1));
}

for (i, (original, update)) in parsed.upstreams.iter().zip(upstreams).enumerate() {
match (original, update) {
Expand Down

0 comments on commit 47f9149

Please sign in to comment.