From 6ea5444d8db0cf22718fdd7b29110d1474350ca7 Mon Sep 17 00:00:00 2001 From: messense Date: Tue, 15 Aug 2023 20:16:51 +0800 Subject: [PATCH] Fix non interactive check when username/password was supplied from cli --- src/upload.rs | 5 ++--- tests/cmd/publish.stdout | 2 ++ tests/cmd/upload.stdout | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/upload.rs b/src/upload.rs index a547bc0ed..53797aeb4 100644 --- a/src/upload.rs +++ b/src/upload.rs @@ -45,7 +45,7 @@ pub struct PublishOpt { /// Password for pypi or your custom registry. /// /// Can also be set via MATURIN_PASSWORD environment variable. - #[arg(short, long)] + #[arg(short, long, env = "MATURIN_PASSWORD", hide_env_values = true)] password: Option, /// Continue uploading files if one already exists. /// (Only valid when uploading to PyPI. Other implementations may not support this.) @@ -235,14 +235,13 @@ fn resolve_pypi_cred( } // fallback to username and password - if opt.non_interactive { + if opt.non_interactive && (opt.username.is_none() || opt.password.is_none()) { bail!("Credentials not found and non-interactive mode is enabled"); } let username = opt.username.clone().unwrap_or_else(get_username); let password = opt .password .clone() - .or_else(|| env::var("MATURIN_PASSWORD").ok()) .unwrap_or_else(|| get_password(&username)); Ok((username, password)) } diff --git a/tests/cmd/publish.stdout b/tests/cmd/publish.stdout index 3329c61a6..900622b69 100644 --- a/tests/cmd/publish.stdout +++ b/tests/cmd/publish.stdout @@ -45,6 +45,8 @@ Options: Password for pypi or your custom registry. Can also be set via MATURIN_PASSWORD environment variable. + + [env: MATURIN_PASSWORD] --skip-existing Continue uploading files if one already exists. (Only valid when uploading to PyPI. Other diff --git a/tests/cmd/upload.stdout b/tests/cmd/upload.stdout index dfbda34ba..5568a5ecc 100644 --- a/tests/cmd/upload.stdout +++ b/tests/cmd/upload.stdout @@ -38,6 +38,8 @@ Options: Password for pypi or your custom registry. Can also be set via MATURIN_PASSWORD environment variable. + + [env: MATURIN_PASSWORD] --skip-existing Continue uploading files if one already exists. (Only valid when uploading to PyPI. Other