mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-17 13:58:29 +00:00
Turn --verify-hashes
on by default (#9170)
Fixes #9164 Using clap's `default_value_t` makes the `flag` function unhappy, so just set the default when we unwrap. Tested with no flags, `--verify-hashes`, `--no-verify-hashes` and setting in uv.toml --------- Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
This commit is contained in:
parent
5ba186628b
commit
71d9c45393
11 changed files with 1013 additions and 192 deletions
|
@ -9,13 +9,26 @@ pub enum HashCheckingMode {
|
|||
|
||||
impl HashCheckingMode {
|
||||
/// Return the [`HashCheckingMode`] from the command-line arguments, if any.
|
||||
pub fn from_args(require_hashes: bool, verify_hashes: bool) -> Option<Self> {
|
||||
if require_hashes {
|
||||
///
|
||||
/// By default, the hash checking mode is [`HashCheckingMode::Verify`]. If `--require-hashes` is
|
||||
/// passed, the hash checking mode is [`HashCheckingMode::Require`]. If `--no-verify-hashes` is
|
||||
/// passed, then no hash checking is performed.
|
||||
pub fn from_args(require_hashes: Option<bool>, verify_hashes: Option<bool>) -> Option<Self> {
|
||||
if require_hashes == Some(true) {
|
||||
// Given `--require-hashes`, always require hashes, regardless of any other flags.
|
||||
Some(Self::Require)
|
||||
} else if verify_hashes {
|
||||
} else if verify_hashes == Some(true) {
|
||||
// Given `--verify-hashes`, always verify hashes, regardless of any other flags.
|
||||
Some(Self::Verify)
|
||||
} else {
|
||||
} else if verify_hashes == Some(false) {
|
||||
// Given `--no-verify-hashes` (without `--require-hashes`), do not verify hashes.
|
||||
None
|
||||
} else if require_hashes == Some(false) {
|
||||
// Given `--no-require-hashes` (without `--verify-hashes`), do not require hashes.
|
||||
None
|
||||
} else {
|
||||
// By default, verify hashes.
|
||||
Some(Self::Verify)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue