MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / read_crate

Function read_crate

scripts/publish.rs:258–301  ·  view source on GitHub ↗
(ws: Option<&Workspace>, manifest: &Path)

Source from the content-addressed store, hash-verified

256}
257
258fn 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
303fn bump_version(krate: &Crate, crates: &[Crate], patch: bool) {
304 println!("bumping `{}`...", krate.name);

Callers 4

mainFunction · 0.85
find_cratesFunction · 0.85
update_capi_versionFunction · 0.85
verify_capiFunction · 0.85

Calls 6

read_to_stringFunction · 0.85
unwrapMethod · 0.45
is_noneMethod · 0.45
to_stringMethod · 0.45
replaceMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected