(ws: Option<&Workspace>, manifest: &Path)
| 256 | } |
| 257 | |
| 258 | fn read_crate(ws: Option<&Workspace>, manifest: &Path) -> Crate { |
| 259 | let mut name = None; |
| 260 | let mut version = None; |
| 261 | let mut publish = true; |
| 262 | for line in fs::read_to_string(manifest).unwrap().lines() { |
| 263 | if name.is_none() && line.starts_with("name = \"") { |
| 264 | name = Some( |
| 265 | line.replace("name = \"", "") |
| 266 | .replace("\"", "") |
| 267 | .trim() |
| 268 | .to_string(), |
| 269 | ); |
| 270 | } |
| 271 | if version.is_none() && line.starts_with("version = \"") { |
| 272 | version = Some( |
| 273 | line.replace("version = \"", "") |
| 274 | .replace("\"", "") |
| 275 | .trim() |
| 276 | .to_string(), |
| 277 | ); |
| 278 | } |
| 279 | if let Some(ws) = ws { |
| 280 | if version.is_none() && line.starts_with("version.workspace = true") { |
| 281 | version = Some(ws.version.clone()); |
| 282 | } |
| 283 | } |
| 284 | if line.starts_with("publish = false") { |
| 285 | publish = false; |
| 286 | } |
| 287 | } |
| 288 | let name = name.unwrap(); |
| 289 | let version = version.unwrap(); |
| 290 | assert!( |
| 291 | !publish || CRATES_TO_PUBLISH.contains(&&name[..]), |
| 292 | "a crate must either be listed in `CRATES_TO_PUBLISH` or have `publish = false` \ |
| 293 | in its `Cargo.toml`" |
| 294 | ); |
| 295 | Crate { |
| 296 | manifest: manifest.to_path_buf(), |
| 297 | name, |
| 298 | version, |
| 299 | publish, |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | fn bump_version(krate: &Crate, crates: &[Crate], patch: bool) { |
| 304 | println!("bumping `{}`...", krate.name); |
no test coverage detected