From c8eebb59abff2c82204cf9363e5e9c2d32c21403 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Mon, 2 Feb 2026 08:37:56 -0600 Subject: [PATCH] Hint on `uv version --bump dev` similar to pre-release bumps (#17796) See https://github.com/astral-sh/uv/issues/17792 --- crates/uv/src/commands/project/version.rs | 5 +++ crates/uv/tests/it/version.rs | 54 +++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/crates/uv/src/commands/project/version.rs b/crates/uv/src/commands/project/version.rs index ae4e84d18..0d359b723 100644 --- a/crates/uv/src/commands/project/version.rs +++ b/crates/uv/src/commands/project/version.rs @@ -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 `" )); } + 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 `" + )); + } return Err(anyhow!( "{old_version} => {new_version} didn't increase the version; provide the exact version to force an update" )); diff --git a/crates/uv/tests/it/version.rs b/crates/uv/tests/it/version.rs index 430a81c8e..4f6c70d9f 100644 --- a/crates/uv/tests/it/version.rs +++ b/crates/uv/tests/it/version.rs @@ -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 ` + "); + 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 ` + "); + Ok(()) +} + // --bump major twice #[test] fn bump_double_major() -> Result<()> {