Skip to content

Commit

Permalink
Allow downgrading smithy-rs versions (#3316)
Browse files Browse the repository at this point in the history
## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->

## Description
<!--- Describe your changes in detail -->

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
  • Loading branch information
rcoh authored Dec 13, 2023
1 parent 49dae16 commit 5a0e434
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
*/

use crate::fs::Fs;
use anyhow::{anyhow, bail, Context};
use anyhow::{anyhow, Context};
use clap::Parser;
use once_cell::sync::Lazy;
use regex::Regex;
use smithy_rs_tool_common::package::PackageStability;
use std::borrow::Cow;
use std::path::{Path, PathBuf};
use tracing::warn;

static STABLE_VERSION_REGEX: Lazy<Regex> = Lazy::new(|| {
Regex::new(
Expand Down Expand Up @@ -104,7 +105,8 @@ fn update_gradle_properties<'a>(
// Special version tag used on the `main` branch
&& current_version != semver::Version::parse("0.0.0-smithy-rs-head").unwrap()
{
bail!("Moving from {current_version} to {upgraded_version} would be a *downgrade*. This command doesn't allow it!");
// NOTE: do not backport this change to mainline during merge.
warn!("Moving from {current_version} to {upgraded_version} is a *downgrade*.");
}
Ok(version_regex.replace(gradle_properties, format!("${{field}}{}", upgraded_version)))
}
Expand Down Expand Up @@ -187,7 +189,9 @@ mod tests {
assert_eq!("smithy.rs.runtime.crate.stable.version=1.0.3", updated);
}

// ignored: we are temporarily removing this safeguard
#[test]
#[ignore]
fn downgrading_stable_crate_should_be_caught_as_err() {
let gradle_properties = "smithy.rs.runtime.crate.stable.version=1.0.2";
let version = semver::Version::new(1, 0, 1);
Expand All @@ -197,7 +201,9 @@ mod tests {
assert!(format!("{:?}", result).contains("downgrade"));
}

// ignored: we are temporarily removing this safeguard
#[test]
#[ignore]
fn downgrading_unstable_crate_should_be_caught_as_err() {
let gradle_properties = "smithy.rs.runtime.crate.unstable.version=0.57.1";
let version = semver::Version::new(0, 57, 0);
Expand Down

0 comments on commit 5a0e434

Please sign in to comment.