MCPcopy Index your code
hub / github.com/AI45Lab/Code / git_command

Method git_command

sdk/python/src/lib.rs:2294–2313  ·  view source on GitHub ↗

Execute a git command with an object-shaped API. Preferred over the positional ``git(...)`` overload for new callers. Example: session.git_command({"command": "status"}) session.git_command({"command": "worktree", "subcommand": "list"})

(&self, py: Python<'_>, args: &Bound<'_, PyDict>)

Source from the content-addressed store, hash-verified

2292 /// session.git_command({"command": "status"})
2293 /// session.git_command({"command": "worktree", "subcommand": "list"})
2294 fn git_command(&self, py: Python<'_>, args: &Bound<'_, PyDict>) -> PyResult<PyToolResult> {
2295 let json_str = py_dict_to_json(args)?;
2296 let args: serde_json::Value = serde_json::from_str(&json_str)
2297 .map_err(|e| PyValueError::new_err(format!("Invalid git args: {e}")))?;
2298 let args = normalize_git_args(args)?;
2299 let session = self.inner.clone();
2300 let result = py
2301 .allow_threads(move || get_runtime().block_on(session.tool("git", args)))
2302 .map_err(|e| PyRuntimeError::new_err(format!("git failed: {e}")))?;
2303 Ok(PyToolResult {
2304 name: result.name,
2305 output: result.output,
2306 exit_code: result.exit_code,
2307 metadata_json: result.metadata.as_ref().map(serde_json::Value::to_string),
2308 error_kind_json: result
2309 .error_kind
2310 .as_ref()
2311 .and_then(|k| serde_json::to_string(k).ok()),
2312 })
2313 }
2314
2315 // ========================================================================
2316 // Advanced optional Queue API

Callers

nothing calls this directly

Calls 6

py_dict_to_jsonFunction · 0.85
block_onMethod · 0.80
normalize_git_argsFunction · 0.70
get_runtimeFunction · 0.70
cloneMethod · 0.45
toolMethod · 0.45

Tested by

no test coverage detected