Show commit log.
(&self, args: &serde_json::Value, git: &dyn WorkspaceGit)
| 201 | |
| 202 | /// Show commit log. |
| 203 | async fn log(&self, args: &serde_json::Value, git: &dyn WorkspaceGit) -> Result<ToolOutput> { |
| 204 | let max_count = args.get("max_count").and_then(|v| v.as_u64()).unwrap_or(10) as usize; |
| 205 | |
| 206 | match git.log(max_count).await { |
| 207 | Ok(commits) => { |
| 208 | if commits.is_empty() { |
| 209 | return Ok(ToolOutput::success("No commits found.")); |
| 210 | } |
| 211 | |
| 212 | let entries: Vec<String> = commits |
| 213 | .iter() |
| 214 | .map(|commit| { |
| 215 | format!( |
| 216 | "{} - {} ({})\n {}", |
| 217 | short_commit_id(&commit.id), |
| 218 | commit.author, |
| 219 | commit.date, |
| 220 | commit.message |
| 221 | ) |
| 222 | }) |
| 223 | .collect(); |
| 224 | |
| 225 | Ok(ToolOutput::success(format!( |
| 226 | "Commit log ({} entries):\n\n{}", |
| 227 | commits.len(), |
| 228 | entries.join("\n\n") |
| 229 | )) |
| 230 | .with_metadata(serde_json::json!({ "count": commits.len() }))) |
| 231 | } |
| 232 | Err(e) => Ok(ToolOutput::error(format!("Failed to get log: {e}"))), |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | /// Branch operations: list or create. |
| 237 | async fn branch(&self, args: &serde_json::Value, git: &dyn WorkspaceGit) -> Result<ToolOutput> { |
no test coverage detected