MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / getCommitInfo

Function getCommitInfo

src/utils/git.ts:279–318  ·  view source on GitHub ↗
(hash: string, cwd: string)

Source from the content-addressed store, hash-verified

277}
278
279export async function getCommitInfo(hash: string, cwd: string): Promise<string> {
280 try {
281 const isInstalled = await checkGitInstalled()
282 if (!isInstalled) {
283 return "Git is not installed"
284 }
285
286 const isRepo = await checkGitRepo(cwd)
287 if (!isRepo) {
288 return "Not a git repository"
289 }
290
291 // Get commit info, stats, and diff separately
292 const { stdout: info } = await execAsync(`git show --format="%H%n%h%n%s%n%an%n%ad%n%b" --no-patch ${hash}`, {
293 cwd,
294 })
295 const [fullHash, shortHash, subject, author, date, body] = info.trim().split("\n")
296
297 const { stdout: stats } = await execAsync(`git show --stat --format="" ${hash}`, { cwd })
298
299 const { stdout: diff } = await execAsync(`git show --format="" ${hash}`, { cwd })
300
301 const summary = [
302 `Commit: ${shortHash} (${fullHash})`,
303 `Author: ${author}`,
304 `Date: ${date}`,
305 `\nMessage: ${subject}`,
306 body ? `\nDescription:\n${body}` : "",
307 "\nFiles Changed:",
308 stats.trim(),
309 "\nFull Changes:",
310 ].join("\n")
311
312 const output = summary + "\n\n" + diff.trim()
313 return truncateOutput(output, GIT_OUTPUT_LINE_LIMIT)
314 } catch (error) {
315 console.error("Error getting commit info:", error)
316 return `Failed to get commit info: ${error instanceof Error ? error.message : String(error)}`
317 }
318}
319
320export async function getWorkingState(cwd: string): Promise<string> {
321 try {

Callers 2

git.spec.tsFile · 0.90
parseMentionsFunction · 0.90

Calls 5

truncateOutputFunction · 0.90
checkGitInstalledFunction · 0.85
checkGitRepoFunction · 0.85
StringInterface · 0.70
errorMethod · 0.65

Tested by

no test coverage detected