From fe29eb5d58257bc3c6406fcc7fedda6c9c3c699d Mon Sep 17 00:00:00 2001 From: konstin Date: Tue, 28 Jan 2025 18:06:29 +0100 Subject: [PATCH] Document `gather_credentials` --- crates/uv/src/commands/publish.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/crates/uv/src/commands/publish.rs b/crates/uv/src/commands/publish.rs index b3405ccd9d07..cef9c7833a50 100644 --- a/crates/uv/src/commands/publish.rs +++ b/crates/uv/src/commands/publish.rs @@ -161,6 +161,34 @@ enum Prompt { /// Unify the different possible source for username and password information. /// +/// Possible credential sources are environment variables, the CLI, the URL, the keyring, trusted +/// publishing or a prompt. +/// +/// The username can come from, in order: +/// +/// - Mutually exclusive: +/// - `--username` or `UV_PUBLISH_USERNAME`. The CLI option overrides the environment variable +/// - The username field in the publish URL +/// - If `--token` or `UV_PUBLISH_TOKEN` are used, it is `__token__`. The CLI option +/// overrides the environment variable +/// - If trusted publishing is available, it is `__token__` +/// - (We currently do not read the username from the keyring) +/// - If stderr is a tty, prompt the user +/// +/// The password can come from, in order: +/// +/// - Mutually exclusive: +/// - `--password` or `UV_PUBLISH_PASSWORD`. The CLI option overrides the environment variable +/// - The password field in the publish URL +/// - If `--token` or `UV_PUBLISH_TOKEN` are used, it is the token value. The CLI option overrides +/// the environment variable +/// - If the keyring is enabled, the keyring entry for the URL and username +/// - If trusted publishing is available, the trusted publishing token +/// - If stderr is a tty, prompt the user +/// +/// If no credentials are found, the auth middleware does a final check for cached credentials and +/// otherwise errors without sending the request. +/// /// Returns the publish URL, the username and the password. async fn gather_credentials( mut publish_url: Url,