From 84285b69e68db02e59a22a74354e37f040d936d1 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Sun, 8 Dec 2024 10:02:00 -0600 Subject: [PATCH] Reframe `--locked` and `--frozen` as `--check` operations for `uv lock` (#9662) Closes https://github.com/astral-sh/uv/issues/7639 --- crates/uv-cli/src/lib.rs | 22 +++++++++++++--------- crates/uv/src/settings.rs | 8 ++++---- docs/concepts/projects/sync.md | 8 ++++++++ docs/reference/cli.md | 20 ++++++++++++-------- 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index e4f1f04df084..959694f75f93 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -3042,22 +3042,26 @@ pub struct SyncArgs { #[derive(Args)] #[allow(clippy::struct_excessive_bools)] pub struct LockArgs { - /// Assert that the `uv.lock` will remain unchanged. + /// Check if the lockfile is up-to-date. /// - /// Requires that the lockfile is up-to-date. If the lockfile is missing or - /// needs to be updated, uv will exit with an error. - #[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "frozen")] - pub locked: bool, + /// Asserts that the `uv.lock` would remain unchanged after a resolution. If the lockfile is + /// missing or needs to be updated, uv will exit with an error. + /// + /// Equivalent to `--locked`. + #[arg(long, alias = "locked", env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "check_exists")] + pub check: bool, - /// Assert that a `uv.lock` exists, without updating it. - #[arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "locked")] - pub frozen: bool, + /// Assert that a `uv.lock` exists without checking if it is up-to-date. + /// + /// Equivalent to `--frozen`. + #[arg(long, alias = "frozen", env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "check")] + pub check_exists: bool, /// Perform a dry run, without writing the lockfile. /// /// In dry-run mode, uv will resolve the project's dependencies and report on the resulting /// changes, but will not write the lockfile to disk. - #[arg(long, conflicts_with = "frozen", conflicts_with = "locked")] + #[arg(long, conflicts_with = "check_exists", conflicts_with = "check")] pub dry_run: bool, #[command(flatten)] diff --git a/crates/uv/src/settings.rs b/crates/uv/src/settings.rs index b2ddf1376f65..05f1fb548172 100644 --- a/crates/uv/src/settings.rs +++ b/crates/uv/src/settings.rs @@ -990,8 +990,8 @@ impl LockSettings { #[allow(clippy::needless_pass_by_value)] pub(crate) fn resolve(args: LockArgs, filesystem: Option) -> Self { let LockArgs { - locked, - frozen, + check, + check_exists, dry_run, resolver, build, @@ -1005,8 +1005,8 @@ impl LockSettings { .unwrap_or_default(); Self { - locked, - frozen, + locked: check, + frozen: check_exists, dry_run, python: python.and_then(Maybe::into_option), refresh: Refresh::from(refresh), diff --git a/docs/concepts/projects/sync.md b/docs/concepts/projects/sync.md index 469123def1f9..bb1bc0fddb73 100644 --- a/docs/concepts/projects/sync.md +++ b/docs/concepts/projects/sync.md @@ -27,6 +27,14 @@ To avoid updating the environment during `uv run` invocations, use the `--no-syn To assert the lockfile matches the project metadata, use the `--locked` flag. If the lockfile is not up-to-date, an error will be raised instead of updating the lockfile. +You can also check if the lockfile is up-to-date by passing the `--check` flag to `uv lock`: + +```console +$ uv lock --check +``` + +This is equivalent to the `--locked` flag for other commands. + ### Upgrading locked package versions By default, uv will prefer the locked versions of packages when running `uv sync` and `uv lock`. diff --git a/docs/reference/cli.md b/docs/reference/cli.md index afd36fd647ed..691abdef064c 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -1790,6 +1790,18 @@ uv lock [OPTIONS]

To view the location of the cache directory, run uv cache dir.

May also be set with the UV_CACHE_DIR environment variable.

+
--check

Check if the lockfile is up-to-date.

+ +

Asserts that the uv.lock would remain unchanged after a resolution. If the lockfile is missing or needs to be updated, uv will exit with an error.

+ +

Equivalent to --locked.

+ +

May also be set with the UV_LOCKED environment variable.

+
--check-exists

Assert that a uv.lock exists without checking if it is up-to-date.

+ +

Equivalent to --frozen.

+ +

May also be set with the UV_FROZEN environment variable.

--color color-choice

Control colors in output

[default: auto]

@@ -1845,9 +1857,6 @@ uv lock [OPTIONS]

If a URL, the page must contain a flat list of links to package files adhering to the formats described above.

May also be set with the UV_FIND_LINKS environment variable.

-
--frozen

Assert that a uv.lock exists, without updating it

- -

May also be set with the UV_FROZEN environment variable.

--help, -h

Display the concise help for this command

--index index

The URLs to use when resolving dependencies, in addition to the default index.

@@ -1910,11 +1919,6 @@ uv lock [OPTIONS]
  • symlink: Symbolically link packages from the wheel into the site-packages directory
  • -
    --locked

    Assert that the uv.lock will remain unchanged.

    - -

    Requires that the lockfile is up-to-date. If the lockfile is missing or needs to be updated, uv will exit with an error.

    - -

    May also be set with the UV_LOCKED environment variable.

    --native-tls

    Whether to load TLS certificates from the platform’s native certificate store.

    By default, uv loads certificates from the bundled webpki-roots crate. The webpki-roots are a reliable set of trust roots from Mozilla, and including them in uv improves portability and performance (especially on macOS).