Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non interactive mode check when username/password was supplied from cli #1737

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
/// Continue uploading files if one already exists.
/// (Only valid when uploading to PyPI. Other implementations may not support this.)
Expand Down Expand Up @@ -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))
}
Expand Down
2 changes: 2 additions & 0 deletions tests/cmd/publish.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/cmd/upload.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down