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)
| 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 | /// |
no test coverage detected