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

Method parse

atomic-cli/src/commands/revise.rs:111–127  ·  view source on GitHub ↗

Parse a change reference string. Supported formats: - `@` or empty: Last change - `@~1`, `@~2`, etc.: Relative to last - Anything else: Treated as hash/hash prefix

(s: &str)

Source from the content-addressed store, hash-verified

109 /// - `@~1`, `@~2`, etc.: Relative to last
110 /// - Anything else: Treated as hash/hash prefix
111 pub fn parse(s: &str) -> Self {
112 let s = s.trim();
113
114 if s.is_empty() || s == "@" {
115 return Self::Last;
116 }
117
118 // Check for @~N pattern
119 if let Some(rest) = s.strip_prefix("@~") {
120 if let Ok(n) = rest.parse::<u64>() {
121 return Self::Relative(n);
122 }
123 }
124
125 // Treat as hash
126 Self::Hash(s.to_string())
127 }
128
129 /// Resolve this reference to a sequence number.
130 ///

Callers 2

list_stashesMethod · 0.45
parse_versionFunction · 0.45

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected