MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / parse_version

Function parse_version

atomic-cli/src/commands/update.rs:251–261  ·  view source on GitHub ↗

Parse "0.6.0" or "v0.6.0" into (major, minor, patch). Stable-only — bails on prereleases. The `/releases/latest` API never returns prereleases, so this is safe for v1. Add the `semver` crate when we introduce `--channel nightly`.

(s: &str)

Source from the content-addressed store, hash-verified

249/// returns prereleases, so this is safe for v1. Add the `semver` crate
250/// when we introduce `--channel nightly`.
251fn parse_version(s: &str) -> Option<(u32, u32, u32)> {
252 let s = s.strip_prefix('v').unwrap_or(s);
253 if s.contains('-') {
254 return None;
255 }
256 let mut parts = s.splitn(3, '.');
257 let major = parts.next()?.parse().ok()?;
258 let minor = parts.next()?.parse().ok()?;
259 let patch = parts.next()?.parse().ok()?;
260 Some((major, minor, patch))
261}
262
263// GitHub fetch — kept thin, not unit-tested
264

Callers 1

executeMethod · 0.70

Calls 4

containsMethod · 0.45
okMethod · 0.45
parseMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected