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

Function parse_version

atomic-cli/src/commands/update.rs:250–260  ·  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

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

Callers 1

executeMethod · 0.70

Calls 3

containsMethod · 0.45
parseMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected