Skip to content

Commit 78c50e3

Browse files
committed
Review
1 parent a303e5a commit 78c50e3

File tree

7 files changed

+88
-85
lines changed

7 files changed

+88
-85
lines changed

crates/uv-cli/src/lib.rs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,7 @@ pub struct VersionArgs {
533533

534534
/// Update the project version using the given semantics
535535
///
536-
/// This flag can be passed multiple times to allow going to a new release and entering
537-
/// a prerelease: `--bump patch --bump beta`
536+
/// This flag can be passed multiple times.
538537
#[arg(group = "operation", long)]
539538
pub bump: Vec<VersionBump>,
540539

@@ -615,25 +614,34 @@ pub struct VersionArgs {
615614
// to perform, we sort them and apply them in order, so users don't have to think too hard about it.
616615
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, clap::ValueEnum)]
617616
pub enum VersionBump {
618-
/// Increase the major version (1.2.3 => 2.0.0)
617+
/// Increase the major version (e.g., 1.2.3 => 2.0.0)
619618
Major,
620-
/// Increase the minor version (1.2.3 => 1.3.0)
619+
/// Increase the minor version (e.g., 1.2.3 => 1.3.0)
621620
Minor,
622-
/// Increase the patch version (1.2.3 => 1.2.4)
621+
/// Increase the patch version (e.g., 1.2.3 => 1.2.4)
623622
Patch,
624-
/// Make the version stable (1.2.3b4.post5.dev6 => 1.2.3)
623+
/// Move from a pre-release to stable version (e.g., 1.2.3b4.post5.dev6 => 1.2.3)
625624
///
626-
/// This intentionally clears `.postN` and preserves `+local`
625+
/// Removes all pre-release components, but will not remove "local" components.
627626
Stable,
628-
/// Increase the alpha version (1.2.3a4 => 1.2.3a5)
627+
/// Increase the alpha version (e.g., 1.2.3a4 => 1.2.3a5)
628+
///
629+
/// To move from a stable to a pre-release version, combine this with a stable component, e.g.,
630+
/// for 1.2.3 => 2.0.0a1, you'd also include [`VersionBump::Major`].
629631
Alpha,
630-
/// Increase the beta version (1.2.3b4 => 1.2.3b5)
632+
/// Increase the beta version (e.g., 1.2.3b4 => 1.2.3b5)
633+
///
634+
/// To move from a stable to a pre-release version, combine this with a stable component, e.g.,
635+
/// for 1.2.3 => 2.0.0b1, you'd also include [`VersionBump::Major`].
631636
Beta,
632-
/// Increase the rc version (1.2.3rc4 => 1.2.3rc5)
637+
/// Increase the rc version (e.g., 1.2.3rc4 => 1.2.3rc5)
638+
///
639+
/// To move from a stable to a pre-release version, combine this with a stable component, e.g.,
640+
/// for 1.2.3 => 2.0.0rc1, you'd also include [`VersionBump::Major`].]
633641
Rc,
634-
/// Increase the post version (1.2.3.post5 => 1.2.3.post6)
642+
/// Increase the post version (e.g., 1.2.3.post5 => 1.2.3.post6)
635643
Post,
636-
/// Increase the dev version (1.2.3a4.dev6 => 1.2.3.dev7)
644+
/// Increase the dev version (e.g., 1.2.3a4.dev6 => 1.2.3.dev7)
637645
Dev,
638646
}
639647

crates/uv/src/commands/project/version.rs

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -205,21 +205,26 @@ pub(crate) async fn project_version(
205205
// Very little reason to do "bump to stable" and then do other things,
206206
// even if we can make sense of it.
207207
if stable_count > 0 && bump.len() > 1 {
208-
if let Some(component) = release_components.first() {
209-
return Err(anyhow!(
210-
"`--bump stable` isn't needed if you're already passing `--bump {component}`"
211-
));
212-
}
208+
let components = bump
209+
.iter()
210+
.map(ToString::to_string)
211+
.collect::<Vec<_>>()
212+
.join(", ");
213213
return Err(anyhow!(
214-
"`--bump stable` cannot be combined with any other `--bump`"
214+
"`--bump stable` cannot be used with another `--bump` value, got: {components}"
215215
));
216216
}
217217

218218
// Very little reason to "bump to post" and then do other things,
219219
// how is it a post-release otherwise?
220220
if post_count > 0 && bump.len() > 1 {
221+
let components = bump
222+
.iter()
223+
.map(ToString::to_string)
224+
.collect::<Vec<_>>()
225+
.join(", ");
221226
return Err(anyhow!(
222-
"`--bump post` cannot be combined with any other `--bump`"
227+
"`--bump post` cannot be used with another `--bump` value, got: {components}"
223228
));
224229
}
225230

@@ -228,19 +233,29 @@ pub(crate) async fn project_version(
228233
// `--bump major --bump major` perfect sense (1.2.3 => 3.0.0)
229234
// ...but it's weird and probably a mistake?
230235
if release_components.len() > 1 {
236+
let components = release_components
237+
.iter()
238+
.map(ToString::to_string)
239+
.collect::<Vec<_>>()
240+
.join(", ");
231241
return Err(anyhow!(
232-
"`--bump` can only take one of `major`, `minor`, `patch`"
242+
"Only one release version component can be provided to `--bump`, got: {components}"
233243
));
234244
}
235245

236246
// `--bump alpha --bump beta` is basically completely incoherent
237247
// `--bump beta --bump beta` makes perfect sense (1.2.3b4 => 1.2.3b6)
238248
// ...but it's weird and probably a mistake?
239249
// `--bump beta --bump dev` makes perfect sense (1.2.3 => 1.2.3b1.dev1)
240-
// ...but we want to discourage mixing `dev` with prereleases
250+
// ...but we want to discourage mixing `dev` with pre-releases
241251
if prerelease_components.len() > 1 {
252+
let components = prerelease_components
253+
.iter()
254+
.map(ToString::to_string)
255+
.collect::<Vec<_>>()
256+
.join(", ");
242257
return Err(anyhow!(
243-
"`--bump` can only take one of `alpha`, `beta`, `rc`, `dev`"
258+
"Only one pre-release version component can be provided to `--bump`, got: {components}"
244259
));
245260
}
246261

@@ -274,11 +289,11 @@ pub(crate) async fn project_version(
274289
if new_version <= old_version {
275290
if old_version.is_stable() && new_version.is_pre() {
276291
return Err(anyhow!(
277-
"{old_version} => {new_version} didn't increase the version; when moving to a prerelease you also need to increase the release `--bump patch`?"
292+
"{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>`"
278293
));
279294
}
280295
return Err(anyhow!(
281-
"{old_version} => {new_version} didn't increase the version"
296+
"{old_version} => {new_version} didn't increase the version; provide the exact version to force an update"
282297
));
283298
}
284299

crates/uv/tests/it/version.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ requires-python = ">=3.12"
601601
----- stdout -----
602602
603603
----- stderr -----
604-
error: `--bump post` cannot be combined with any other `--bump`
604+
error: `--bump post` cannot be used with another `--bump` value, got: major, patch, alpha, minor, dev, minor, post, post
605605
");
606606

607607
let pyproject = fs_err::read_to_string(&pyproject_toml)?;
@@ -919,7 +919,7 @@ requires-python = ">=3.12"
919919
----- stdout -----
920920
921921
----- stderr -----
922-
error: 2.3.4.post6 => 2.3.4 didn't increase the version
922+
error: 2.3.4.post6 => 2.3.4 didn't increase the version; provide the exact version to force an update
923923
");
924924
Ok(())
925925
}
@@ -946,7 +946,7 @@ requires-python = ">=3.12"
946946
----- stdout -----
947947
948948
----- stderr -----
949-
error: 2.3.4b5 => 2.3.4a1 didn't increase the version
949+
error: 2.3.4b5 => 2.3.4a1 didn't increase the version; provide the exact version to force an update
950950
");
951951
Ok(())
952952
}
@@ -973,7 +973,7 @@ requires-python = ">=3.12"
973973
----- stdout -----
974974
975975
----- stderr -----
976-
error: 2.3.4 => 2.3.4a1 didn't increase the version; when moving to a prerelease you also need to increase the release `--bump patch`?
976+
error: 2.3.4 => 2.3.4a1 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>`
977977
");
978978
Ok(())
979979
}
@@ -1001,7 +1001,7 @@ requires-python = ">=3.12"
10011001
----- stdout -----
10021002
10031003
----- stderr -----
1004-
error: `--bump` can only take one of `major`, `minor`, `patch`
1004+
error: Only one release version component can be provided to `--bump`, got: major, major
10051005
");
10061006
Ok(())
10071007
}
@@ -1029,7 +1029,7 @@ requires-python = ">=3.12"
10291029
----- stdout -----
10301030
10311031
----- stderr -----
1032-
error: `--bump` can only take one of `alpha`, `beta`, `rc`, `dev`
1032+
error: Only one pre-release version component can be provided to `--bump`, got: alpha, alpha
10331033
");
10341034
Ok(())
10351035
}
@@ -1057,7 +1057,7 @@ requires-python = ">=3.12"
10571057
----- stdout -----
10581058
10591059
----- stderr -----
1060-
error: `--bump stable` isn't needed if you're already passing `--bump major`
1060+
error: `--bump stable` cannot be used with another `--bump` value, got: stable, major
10611061
");
10621062
Ok(())
10631063
}
@@ -1145,7 +1145,7 @@ requires-python = ">=3.12"
11451145
----- stdout -----
11461146
11471147
----- stderr -----
1148-
error: `--bump` can only take one of `alpha`, `beta`, `rc`, `dev`
1148+
error: Only one pre-release version component can be provided to `--bump`, got: alpha, dev
11491149
");
11501150
Ok(())
11511151
}
@@ -1203,7 +1203,7 @@ requires-python = ">=3.12"
12031203
----- stdout -----
12041204
12051205
----- stderr -----
1206-
error: `--bump post` cannot be combined with any other `--bump`
1206+
error: `--bump post` cannot be used with another `--bump` value, got: major, post
12071207
");
12081208
Ok(())
12091209
}

docs/concepts/projects/config.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@ Setting `tool.uv.package = false` will force a project package _not_ to be built
160160
the project environment. uv will ignore a declared build system when interacting with the project;
161161
however, uv will still respect explicit attempts to build the project such as invoking `uv build`.
162162

163-
## Project versioning
164-
165163
## Project environment path
166164

167165
The `UV_PROJECT_ENVIRONMENT` environment variable can be used to configure the project virtual

docs/guides/package.md

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ The `uv version` command provides conveniences for updating the version of your
6161
publish it.
6262
[See the project docs for reading your package's version](./projects.md#managing-version).
6363

64-
To set the the exact version of your package, just pass that version:
64+
To update to an exact version, provide it as a positional argument:
6565

6666
```console
6767
$ uv version 1.0.0
6868
hello-world 0.7.0 => 1.0.0
6969
```
7070

71-
If you want to preview the change without actually applying it, use the `--dry-run` flag:
71+
To preview the change without updating the `pyproject.toml`, use the `--dry-run` flag:
7272

7373
```console
7474
$ uv version 2.0.0 --dry-run
@@ -77,49 +77,37 @@ $ uv version
7777
hello-world 1.0.0
7878
```
7979

80-
If you want to change the version of a particular package, use the `--package` flag:
81-
82-
```console
83-
$ uv version --package hello-world 1.2.3
84-
hello-world 1.0.0 => 1.2.3
85-
```
86-
87-
To increase the version of your package, use the `--bump` flag:
80+
To increase the version of your package semantics, use the `--bump` option:
8881

8982
```console
9083
$ uv version --bump minor
9184
hello-world 1.2.3 => 1.3.0
9285
```
9386

94-
The `--bump` flag can be passed multiple times, and uv will run them in the following order that
95-
prevents bumps from clobbering eachother:
87+
The `--bump` option supports the following common version components: `major`, `minor`, `patch`,
88+
`stable`, `alpha`, `beta`, `rc`, `post`, and `dev`. When provided more than once, the components
89+
will be applied in order, from largest (`major`) to smallest (`dev`).
9690

97-
```text
98-
major > minor > patch > stable > alpha > beta > rc > post > dev
99-
```
100-
101-
When you're on a stable version and want to start shipping prereleases, you'll want to bump the
102-
release and the prerelease:
91+
To move from a stable to pre-release version, bump one of the major, minor, or patch components in
92+
addition to the pre-release component:
10393

10494
```console
10595
$ uv version --bump patch --bump beta
10696
hello-world 1.3.0 => 1.3.1b1
97+
$ uv version --bump major --bump alpha
98+
hello-world 1.3.0 => 2.0.0a1
10799
```
108100

109-
!!! Note
110-
111-
If you only bump the prerelease here it will actually decrease the current version.
112-
`uv version` will error if that ever happens. If you intended to do that, you can pass
113-
`--allow-decreases` to disable the check.
114-
115-
When you're on a prerelease and want to ship another, you can just bump the prerelease:
101+
When moving from a pre-release to a new pre-release version, just bump the relevant pre-release
102+
component:
116103

117104
```console
118105
uv version --bump beta
119106
hello-world 1.3.0b1 => 1.3.1b2
120107
```
121108

122-
When you're on a prerelease and want to ship a stable version, you can bump to stable:
109+
When moving from a pre-release to a stable version, the `stable` option can be used to clear the
110+
pre-release component:
123111

124112
```console
125113
uv version --bump stable
@@ -128,9 +116,8 @@ hello-world 1.3.1b2 => 1.3.1
128116

129117
!!! info
130118

131-
By default, when `uv version` modifies your package it will lock and sync your project to
132-
ensure everything sees the change. To prevent locking and syncing, pass `--frozen`. To just
133-
prevent syncing, pass `--no-sync`.
119+
By default, when `uv version` modifies the project it will perform a lock and sync. To
120+
prevent locking and syncing, use `--frozen`, or, to just prevent syncing, use `--no-sync`.
134121

135122
## Publishing your package
136123

docs/guides/projects.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,30 +163,22 @@ details.
163163
## Managing version
164164

165165
The `uv version` command can be used to read your package's version.
166-
[See the publishing docs for updating your package's version](./package.md#updating-your-version).
167166

168-
To get the version of your package, run `uv version` with no other arguments:
167+
To get the version of your package, run `uv version`:
169168

170169
```console
171170
$ uv version
172171
hello-world 0.7.0
173172
```
174173

175-
To get the version of a particular package, pass `--package`:
176-
177-
```console
178-
$ uv version --package myapp
179-
myapp 1.2.3
180-
```
181-
182-
To just get the version with no other output, pass `--short`:
174+
To get the version without the package name, use the `--short` option:
183175

184176
```console
185177
$ uv version --short
186178
0.7.0
187179
```
188180

189-
To get the version as json, pass `--output-format json`:
181+
To get version information in a JSON format, use the `--output-format json` option:
190182

191183
```console
192184
$ uv version --output-format json
@@ -197,6 +189,9 @@ $ uv version --output-format json
197189
}
198190
```
199191

192+
See the [publishing guide](./package.md#updating-your-version) for details on updating your package
193+
version.
194+
200195
## Running commands
201196

202197
`uv run` can be used to run arbitrary scripts or commands in your project environment.

docs/reference/cli.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -787,18 +787,18 @@ uv version [OPTIONS] [VALUE]
787787
<p>Expects to receive either a hostname (e.g., <code>localhost</code>), a host-port pair (e.g., <code>localhost:8080</code>), or a URL (e.g., <code>https://localhost</code>).</p>
788788
<p>WARNING: Hosts included in this list will not be verified against the system's certificate store. Only use <code>--allow-insecure-host</code> in a secure network with verified sources, as it bypasses SSL verification and could expose you to MITM attacks.</p>
789789
<p>May also be set with the <code>UV_INSECURE_HOST</code> environment variable.</p></dd><dt id="uv-version--bump"><a href="#uv-version--bump"><code>--bump</code></a> <i>bump</i></dt><dd><p>Update the project version using the given semantics</p>
790-
<p>This flag can be passed multiple times to allow going to a new release and entering a prerelease: <code>--bump patch --bump beta</code></p>
790+
<p>This flag can be passed multiple times.</p>
791791
<p>Possible values:</p>
792792
<ul>
793-
<li><code>major</code>: Increase the major version (1.2.3 =&gt; 2.0.0)</li>
794-
<li><code>minor</code>: Increase the minor version (1.2.3 =&gt; 1.3.0)</li>
795-
<li><code>patch</code>: Increase the patch version (1.2.3 =&gt; 1.2.4)</li>
796-
<li><code>stable</code>: Make the version stable (1.2.3b4.post5.dev6 =&gt; 1.2.3)</li>
797-
<li><code>alpha</code>: Increase the alpha version (1.2.3a4 =&gt; 1.2.3a5)</li>
798-
<li><code>beta</code>: Increase the beta version (1.2.3b4 =&gt; 1.2.3b5)</li>
799-
<li><code>rc</code>: Increase the rc version (1.2.3rc4 =&gt; 1.2.3rc5)</li>
800-
<li><code>post</code>: Increase the post version (1.2.3.post5 =&gt; 1.2.3.post6)</li>
801-
<li><code>dev</code>: Increase the dev version (1.2.3a4.dev6 =&gt; 1.2.3.dev7)</li>
793+
<li><code>major</code>: Increase the major version (e.g., 1.2.3 =&gt; 2.0.0)</li>
794+
<li><code>minor</code>: Increase the minor version (e.g., 1.2.3 =&gt; 1.3.0)</li>
795+
<li><code>patch</code>: Increase the patch version (e.g., 1.2.3 =&gt; 1.2.4)</li>
796+
<li><code>stable</code>: Move from a pre-release to stable version (e.g., 1.2.3b4.post5.dev6 =&gt; 1.2.3)</li>
797+
<li><code>alpha</code>: Increase the alpha version (e.g., 1.2.3a4 =&gt; 1.2.3a5)</li>
798+
<li><code>beta</code>: Increase the beta version (e.g., 1.2.3b4 =&gt; 1.2.3b5)</li>
799+
<li><code>rc</code>: Increase the rc version (e.g., 1.2.3rc4 =&gt; 1.2.3rc5)</li>
800+
<li><code>post</code>: Increase the post version (e.g., 1.2.3.post5 =&gt; 1.2.3.post6)</li>
801+
<li><code>dev</code>: Increase the dev version (e.g., 1.2.3a4.dev6 =&gt; 1.2.3.dev7)</li>
802802
</ul></dd><dt id="uv-version--cache-dir"><a href="#uv-version--cache-dir"><code>--cache-dir</code></a> <i>cache-dir</i></dt><dd><p>Path to the cache directory.</p>
803803
<p>Defaults to <code>$XDG_CACHE_HOME/uv</code> or <code>$HOME/.cache/uv</code> on macOS and Linux, and <code>%LOCALAPPDATA%\uv\cache</code> on Windows.</p>
804804
<p>To view the location of the cache directory, run <code>uv cache dir</code>.</p>

0 commit comments

Comments
 (0)