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

Function bump_version

scripts/publish.rs:303–382  ·  view source on GitHub ↗
(krate: &Crate, crates: &[Crate], patch: bool)

Source from the content-addressed store, hash-verified

301}
302
303fn bump_version(krate: &Crate, crates: &[Crate], patch: bool) {
304 println!("bumping `{}`...", krate.name);
305 let contents = fs::read_to_string(&krate.manifest).unwrap();
306 let next_version = |krate: &Crate| -> String {
307 if krate.publish {
308 bump(&krate.version, patch)
309 } else {
310 krate.version.clone()
311 }
312 };
313
314 let mut new_manifest = String::new();
315 let mut is_deps = false;
316 for line in contents.lines() {
317 let mut rewritten = false;
318 if !is_deps && line.starts_with("version =") {
319 if krate.publish {
320 println!(" {} => {}", krate.version, next_version(krate));
321 new_manifest.push_str(&line.replace(&krate.version, &next_version(krate)));
322 rewritten = true;
323 }
324 }
325
326 is_deps = if line.starts_with("[") {
327 line.contains("dependencies")
328 } else {
329 is_deps
330 };
331
332 for other in crates {
333 // If `other` isn't a published crate then it's not going to get a
334 // bumped version so we don't need to update anything in the
335 // manifest.
336 if !other.publish {
337 continue;
338 }
339 if !is_deps
340 || (!line.starts_with(&format!("{} ", other.name))
341 && !(line.contains(&format!("package = '{}'", other.name))
342 || line.contains(&format!("package = \"{}\"", other.name))))
343 {
344 continue;
345 }
346 if !line.contains(&other.version) {
347 if !line.contains("version =") || !krate.publish {
348 continue;
349 }
350 panic!(
351 "{:?} has a dep on {} but doesn't list version {}",
352 krate.manifest, other.name, other.version
353 );
354 }
355 if krate.publish {
356 if PUBLIC_CRATES.contains(&other.name.as_str()) {
357 assert!(
358 !line.contains("\"="),
359 "{} should not have an exact version requirement on {}",
360 krate.name,

Callers 1

mainFunction · 0.85

Calls 10

read_to_stringFunction · 0.85
bumpFunction · 0.85
newFunction · 0.50
writeFunction · 0.50
unwrapMethod · 0.45
cloneMethod · 0.45
push_strMethod · 0.45
replaceMethod · 0.45
containsMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected