Show repository status.
(&self, ctx: &ToolContext, git: &dyn WorkspaceGit)
| 164 | impl GitTool { |
| 165 | /// Show repository status. |
| 166 | async fn status(&self, ctx: &ToolContext, git: &dyn WorkspaceGit) -> Result<ToolOutput> { |
| 167 | match git.status().await { |
| 168 | Ok(status) => { |
| 169 | let status_str = if status.is_dirty { |
| 170 | format!("{} uncommitted change(s)", status.dirty_count) |
| 171 | } else { |
| 172 | "clean".to_string() |
| 173 | }; |
| 174 | |
| 175 | Ok(ToolOutput::success(format!( |
| 176 | "Workspace: {}\n\ |
| 177 | Branch: {}\n\ |
| 178 | Commit: {}\n\ |
| 179 | Status: {}\n\ |
| 180 | Worktree: {}", |
| 181 | ctx.workspace_services.workspace_ref().display_root, |
| 182 | status.branch, |
| 183 | status.commit, |
| 184 | status_str, |
| 185 | if status.is_worktree { |
| 186 | "yes (linked)" |
| 187 | } else { |
| 188 | "no (main)" |
| 189 | } |
| 190 | )) |
| 191 | .with_metadata(serde_json::json!({ |
| 192 | "branch": status.branch, |
| 193 | "is_worktree": status.is_worktree, |
| 194 | "dirty_count": status.dirty_count, |
| 195 | "is_dirty": status.is_dirty, |
| 196 | }))) |
| 197 | } |
| 198 | Err(e) => Ok(ToolOutput::error(format!("Failed to get status: {e}"))), |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | /// Show commit log. |
| 203 | async fn log(&self, args: &serde_json::Value, git: &dyn WorkspaceGit) -> Result<ToolOutput> { |
no test coverage detected