Parses a `(kind, value)` pair from tool arguments. Kinds are `branch`, `worktree`, and `commit`; values are trimmed and normalized per kind.
(kind: &str, value: &str)
| 179 | /// `branch`, `worktree`, and `commit`; values are trimmed and |
| 180 | /// normalized per kind. |
| 181 | pub fn parse(kind: &str, value: &str) -> Result<Self, GitCorrelationError> { |
| 182 | let value = value.trim(); |
| 183 | if value.is_empty() { |
| 184 | return Err(GitCorrelationError::InvalidArgument( |
| 185 | "value must be a non-empty string".to_string(), |
| 186 | )); |
| 187 | } |
| 188 | match kind { |
| 189 | "branch" => Ok(Self::Branch(value.to_string())), |
| 190 | "worktree" => Ok(Self::Worktree(normalize_worktree(value))), |
| 191 | "commit" => parse_commit_sha(value).map(Self::Commit), |
| 192 | other => Err(GitCorrelationError::InvalidArgument(format!( |
| 193 | "git_ref must be one of branch, worktree, commit (got `{other}`)" |
| 194 | ))), |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | pub const fn kind(&self) -> &'static str { |
| 199 | match self { |
nothing calls this directly
no test coverage detected