Apply a unified diff patch to a workspace file.
(&self, py: Python<'_>, path: String, diff: String)
| 2125 | |
| 2126 | /// Apply a unified diff patch to a workspace file. |
| 2127 | fn patch_file(&self, py: Python<'_>, path: String, diff: String) -> PyResult<PyToolResult> { |
| 2128 | let session = self.inner.clone(); |
| 2129 | let result = py |
| 2130 | .allow_threads(move || get_runtime().block_on(session.patch_file(&path, &diff))) |
| 2131 | .map_err(|e| PyRuntimeError::new_err(format!("{e}")))?; |
| 2132 | |
| 2133 | Ok(PyToolResult { |
| 2134 | name: result.name, |
| 2135 | output: result.output, |
| 2136 | exit_code: result.exit_code, |
| 2137 | metadata_json: result.metadata.as_ref().map(serde_json::Value::to_string), |
| 2138 | error_kind_json: result |
| 2139 | .error_kind |
| 2140 | .as_ref() |
| 2141 | .and_then(|k| serde_json::to_string(k).ok()), |
| 2142 | }) |
| 2143 | } |
| 2144 | |
| 2145 | /// Execute a bash command in the workspace. |
| 2146 | fn bash(&self, py: Python<'_>, command: String) -> PyResult<String> { |
no test coverage detected