Skip to content

Commit ba1f16a

Browse files
author
Guanqun Lu
committed
fixes
1 parent 0e5d378 commit ba1f16a

File tree

3 files changed

+7
-17
lines changed

3 files changed

+7
-17
lines changed

src/cargo/ops/registry.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,14 +413,14 @@ pub fn needs_custom_http_transport(config: &Config) -> CargoResult<bool> {
413413
let cainfo = config.get_path("http.cainfo")?;
414414
let check_revoke = config.get_bool("http.check-revoke")?;
415415
let user_agent = config.get_string("http.user-agent")?;
416-
let ssl_version = config.get::<SslVersionConfig>("http.ssl-version")?;
416+
let ssl_version = config.get::<Option<SslVersionConfig>>("http.ssl-version")?;
417417

418418
Ok(proxy_exists
419419
|| timeout
420420
|| cainfo.is_some()
421421
|| check_revoke.is_some()
422422
|| user_agent.is_some()
423-
|| !ssl_version.is_empty())
423+
|| ssl_version.is_some())
424424
}
425425

426426
/// Configure a libcurl http handle with the defaults options for Cargo
@@ -456,7 +456,7 @@ pub fn configure_http_handle(config: &Config, handle: &mut Easy) -> CargoResult<
456456
}
457457
if let Some(ssl_version) = config.get::<Option<SslVersionConfig>>("http.ssl-version")? {
458458
match ssl_version {
459-
SslVersionConfig::Exactly(s) => {
459+
SslVersionConfig::Single(s) => {
460460
let version = to_ssl_version(s.as_str())?;
461461
handle.ssl_version(version)?;
462462
},

src/cargo/util/config.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,7 +1871,7 @@ pub fn clippy_driver() -> PathBuf {
18711871
#[derive(Clone, Debug, Deserialize)]
18721872
#[serde(untagged)]
18731873
pub enum SslVersionConfig {
1874-
Exactly(String),
1874+
Single(String),
18751875
Range(SslVersionConfigRange),
18761876
}
18771877

@@ -1881,13 +1881,3 @@ pub struct SslVersionConfigRange {
18811881
pub max: Option<String>,
18821882
}
18831883

1884-
impl SslVersionConfig {
1885-
pub fn is_empty(&self) -> bool {
1886-
match self {
1887-
SslVersionConfig::Exactly(_) => false,
1888-
SslVersionConfig::Range(SslVersionConfigRange{ min, max}) =>
1889-
min.is_none() && max.is_none(),
1890-
}
1891-
}
1892-
}
1893-

tests/testsuite/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ hello = 'world'
852852
}
853853

854854
#[cargo_test]
855-
fn config_get_ssl_version_exact() {
855+
fn config_get_ssl_version_single() {
856856
write_config(
857857
"\
858858
[http]
@@ -864,7 +864,7 @@ ssl-version = 'tlsv1.2'
864864

865865
let a = config.get::<Option<SslVersionConfig>>("http.ssl-version").unwrap().unwrap();
866866
match a {
867-
SslVersionConfig::Exactly(v) => assert_eq!(&v, "tlsv1.2"),
867+
SslVersionConfig::Single(v) => assert_eq!(&v, "tlsv1.2"),
868868
SslVersionConfig::Range(_) => panic!("Did not expect ssl version min/max."),
869869
};
870870
}
@@ -883,7 +883,7 @@ ssl-version.max = 'tlsv1.3'
883883

884884
let a = config.get::<Option<SslVersionConfig>>("http.ssl-version").unwrap().unwrap();
885885
match a {
886-
SslVersionConfig::Exactly(_) => panic!("Did not expect exact ssl version."),
886+
SslVersionConfig::Single(_) => panic!("Did not expect exact ssl version."),
887887
SslVersionConfig::Range(range) => {
888888
assert_eq!(range.min, Some(String::from("tlsv1.2")));
889889
assert_eq!(range.max, Some(String::from("tlsv1.3")));

0 commit comments

Comments
 (0)