Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions crates/uv/src/commands/project/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ pub(crate) async fn project_version(
"{old_version} => {new_version} didn't increase the version; when bumping to a pre-release version you also need to increase a release version component, e.g., with `--bump <major|minor|patch>`"
));
}
if new_version.is_dev() && !old_version.is_dev() {
return Err(anyhow!(
"{old_version} => {new_version} didn't increase the version; when bumping to a dev version you also need to increase another version component, e.g., with `--bump <major|minor|patch|alpha|beta|rc>`"
));
}
return Err(anyhow!(
"{old_version} => {new_version} didn't increase the version; provide the exact version to force an update"
));
Expand Down
54 changes: 54 additions & 0 deletions crates/uv/tests/it/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,60 @@ requires-python = ">=3.12"
Ok(())
}

// --bump dev but it decreases the version from a stable
#[test]
fn bump_decrease_dev_stable() -> Result<()> {
let context = TestContext::new("3.12");

let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(
r#"
[project]
name = "myproject"
version = "2.3.4"
requires-python = ">=3.12"
"#,
)?;

uv_snapshot!(context.filters(), context.version()
.arg("--bump").arg("dev"), @"
success: false
exit_code: 2
----- stdout -----

----- stderr -----
error: 2.3.4 => 2.3.4.dev1 didn't increase the version; when bumping to a dev version you also need to increase another version component, e.g., with `--bump <major|minor|patch|alpha|beta|rc>`
");
Ok(())
}

// --bump dev but it decreases the version from a pre-release
#[test]
fn bump_decrease_dev_prerelease() -> Result<()> {
let context = TestContext::new("3.12");

let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(
r#"
[project]
name = "myproject"
version = "2.3.4a1"
requires-python = ">=3.12"
"#,
)?;

uv_snapshot!(context.filters(), context.version()
.arg("--bump").arg("dev"), @"
success: false
exit_code: 2
----- stdout -----

----- stderr -----
error: 2.3.4a1 => 2.3.4a1.dev1 didn't increase the version; when bumping to a dev version you also need to increase another version component, e.g., with `--bump <major|minor|patch|alpha|beta|rc>`
");
Ok(())
}

// --bump major twice
#[test]
fn bump_double_major() -> Result<()> {
Expand Down
Loading