MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / parse

Method parse

src/sessions/git_correlation.rs:181–196  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 3

normalize_worktreeFunction · 0.85
parse_commit_shaFunction · 0.85
is_emptyMethod · 0.45

Tested by

no test coverage detected