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

Function getWorkingState

src/utils/git.ts:320–347  ·  view source on GitHub ↗
(cwd: string)

Source from the content-addressed store, hash-verified

318}
319
320export async function getWorkingState(cwd: string): Promise<string> {
321 try {
322 const isInstalled = await checkGitInstalled()
323 if (!isInstalled) {
324 return "Git is not installed"
325 }
326
327 const isRepo = await checkGitRepo(cwd)
328 if (!isRepo) {
329 return "Not a git repository"
330 }
331
332 // Get status of working directory
333 const { stdout: status } = await execAsync("git status --short", { cwd })
334 if (!status.trim()) {
335 return "No changes in working directory"
336 }
337
338 // Get all changes (both staged and unstaged) compared to HEAD
339 const { stdout: diff } = await execAsync("git diff HEAD", { cwd })
340 const lineLimit = GIT_OUTPUT_LINE_LIMIT
341 const output = `Working directory changes:\n\n${status}\n\n${diff}`.trim()
342 return truncateOutput(output, lineLimit)
343 } catch (error) {
344 console.error("Error getting working state:", error)
345 return `Failed to get working state: ${error instanceof Error ? error.message : String(error)}`
346 }
347}
348
349/**
350 * Gets git status output with configurable file limit

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