Skip to content

Commit 8150b60

Browse files
committed
add boolean to struct to support what crates is sending
in case an old version of cargo is being used. the old version should be able to decode the boolean and ignore the string.
1 parent 321c0cd commit 8150b60

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/cargo/ops/registry.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,6 @@ pub fn modify_owners(config: &Config, opts: &OwnersOptions) -> CargoResult<()> {
320320

321321
if let Some(ref v) = opts.to_add {
322322
let v = v.iter().map(|s| &s[..]).collect::<Vec<_>>();
323-
//config.shell().status("Owner", format!("adding {:?} to crate {}",
324-
// v, name))?;
325323
let msg = registry.add_owners(&name, &v).map_err(|e| {
326324
CargoError::from(format!("failed to invite owners to crate {}: {}", name, e))
327325
})?;

src/crates-io/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub struct Warnings {
116116
}
117117

118118
#[derive(Deserialize)] struct R { ok: bool }
119-
#[derive(Deserialize)] struct OwnerResponse { ok: String }
119+
#[derive(Deserialize)] struct OwnerResponse { ok: bool, msg: String }
120120
#[derive(Deserialize)] struct ApiErrorList { errors: Vec<ApiError> }
121121
#[derive(Deserialize)] struct ApiError { detail: String }
122122
#[derive(Serialize)] struct OwnersReq<'a> { users: &'a [&'a str] }
@@ -142,14 +142,15 @@ impl Registry {
142142
let body = serde_json::to_string(&OwnersReq { users: owners })?;
143143
let body = self.put(format!("/crates/{}/owners", krate),
144144
body.as_bytes())?;
145-
Ok(serde_json::from_str::<OwnerResponse>(&body)?.ok)
145+
assert!(serde_json::from_str::<OwnerResponse>(&body)?.ok);
146+
Ok(serde_json::from_str::<OwnerResponse>(&body)?.msg)
146147
}
147148

148149
pub fn remove_owners(&mut self, krate: &str, owners: &[&str]) -> Result<()> {
149150
let body = serde_json::to_string(&OwnersReq { users: owners })?;
150151
let body = self.delete(format!("/crates/{}/owners", krate),
151152
Some(body.as_bytes()))?;
152-
serde_json::from_str::<OwnerResponse>(&body)?;
153+
assert!(serde_json::from_str::<OwnerResponse>(&body)?.ok);
153154
Ok(())
154155
}
155156

0 commit comments

Comments
 (0)