MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / getCommits

Function getCommits

evals/buffbench/pick-commits.ts:122–163  ·  view source on GitHub ↗
(repoPath: string, limit: number, afterCommit?: string)

Source from the content-addressed store, hash-verified

120const userInputId = 'commit-picker'
121
122function getCommits(repoPath: string, limit: number, afterCommit?: string): CommitInfo[] {
123 const gitArgs = [
124 'log',
125 '--pretty=format:%H|%an|%ad|%s',
126 '--date=iso',
127 '-n',
128 limit.toString(),
129 ]
130
131 // If afterCommit is specified, start from that commit's parent
132 if (afterCommit) {
133 gitArgs.push(`${afterCommit}^`) // Start from the parent of the specified commit
134 }
135
136 const gitLogOutput = execFileSync(
137 'git',
138 gitArgs,
139 { cwd: repoPath, encoding: 'utf-8' },
140 )
141
142 const lines = gitLogOutput.split('\n').filter((line) => line.trim() !== '')
143
144 return lines.map((line) => {
145 const [sha, author, date, ...messageParts] = line.split('|')
146 const message = messageParts.join('|')
147
148 // Get stats for this commit
149 const statsOutput = execFileSync('git', ['show', '--stat', sha], {
150 cwd: repoPath,
151 encoding: 'utf-8',
152 })
153 const stats = parseGitStats(statsOutput)
154
155 return {
156 sha,
157 author,
158 date,
159 message,
160 stats,
161 }
162 })
163}
164
165function parseGitStats(statsOutput: string): {
166 filesChanged: number

Callers 1

pickCommitsFunction · 0.85

Calls 1

parseGitStatsFunction · 0.85

Tested by

no test coverage detected