MCPcopy Create free account
hub / github.com/bearlyai/OpenADE / handleGetCommitFiles

Function handleGetCommitFiles

projects/electron/src/modules/code/git.ts:1682–1728  ·  view source on GitHub ↗
(params: GetCommitFilesParams)

Source from the content-addressed store, hash-verified

1680}
1681
1682async function handleGetCommitFiles(params: GetCommitFilesParams): Promise<GetCommitFilesResponse> {
1683 const startTime = Date.now()
1684 const commit = params.commit.trim()
1685 logger.info("[Git:getCommitFiles] Getting changed files for commit", JSON.stringify({
1686 workDir: params.workDir,
1687 commit,
1688 }))
1689
1690 try {
1691 if (!commit) {
1692 throw new Error("commit must be a non-empty string")
1693 }
1694
1695 const parentResult = await execGit(["show", "--no-patch", "--format=%P", commit], params.workDir)
1696 if (!parentResult.success) {
1697 throw new Error(`Failed to resolve commit parents: ${parentResult.stderr}`)
1698 }
1699
1700 const parents = parentResult.stdout.trim().split(/\s+/).filter(Boolean)
1701 const diffResult = parents.length === 0
1702 ? await execGit(
1703 ["diff-tree", "--root", "-r", "--no-commit-id", "--name-status", "-M", commit],
1704 params.workDir
1705 )
1706 : await execGit(
1707 ["diff", "--name-status", "-M", parents[0], commit],
1708 params.workDir
1709 )
1710
1711 if (!diffResult.success) {
1712 throw new Error(`Failed to get commit files: ${diffResult.stderr}`)
1713 }
1714
1715 const files = parseNameStatusOutput(diffResult.stdout)
1716
1717 logger.info("[Git:getCommitFiles] Commit files loaded", JSON.stringify({
1718 count: files.length,
1719 isRootCommit: parents.length === 0,
1720 duration: Date.now() - startTime,
1721 }))
1722
1723 return { files }
1724 } catch (error: any) {
1725 logger.error("[Git:getCommitFiles] Error:", JSON.stringify({ error: error.message, duration: Date.now() - startTime }))
1726 throw error
1727 }
1728}
1729
1730/**
1731 * Get list of files changed between a commit and the working tree.

Callers 1

getRuntimeCommitFilesFunction · 0.85

Calls 3

execGitFunction · 0.85
errorMethod · 0.80
parseNameStatusOutputFunction · 0.70

Tested by

no test coverage detected