Skip to content

Commit

Permalink
Fix non interactive check when username/password was supplied from cli
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Aug 15, 2023
1 parent a8be6e0 commit 246235a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
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")]
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

0 comments on commit 246235a

Please sign in to comment.