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

Method log

core/src/tools/builtin/git.rs:203–234  ·  view source on GitHub ↗

Show commit log.

(&self, args: &serde_json::Value, git: &dyn WorkspaceGit)

Source from the content-addressed store, hash-verified

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> {

Callers 1

executeMethod · 0.45

Calls 3

getMethod · 0.45
is_emptyMethod · 0.45
with_metadataMethod · 0.45

Tested by

no test coverage detected