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

Function screenCommitsWithGpt5

evals/buffbench/pick-commits.ts:338–474  ·  view source on GitHub ↗
(
  commits: CommitInfo[],
  repoUrl: string,
  repoPath: string,
  clientSessionId: string,
)

Source from the content-addressed store, hash-verified

336}
337
338async function screenCommitsWithGpt5(
339 commits: CommitInfo[],
340 repoUrl: string,
341 repoPath: string,
342 clientSessionId: string,
343): Promise<FilteredCommit[]> {
344 const selectedCommits: FilteredCommit[] = []
345 const concurrency = 8
346
347 // Process each commit individually
348 async function processCommit(
349 commit: CommitInfo,
350 index: number,
351 ): Promise<FilteredCommit | null> {
352 console.log(
353 `Screening commit ${index + 1}/${commits.length}: ${commit.sha.substring(0, 8)}...`,
354 )
355
356 // Get detailed commit information including diffs
357 let diffs: CommitDiff[] = []
358 try {
359 diffs = await generateDiffFromCommit(repoPath, commit.sha)
360 } catch (error) {
361 console.warn(`Failed to get diffs for commit ${commit.sha}:`, error)
362 }
363
364 let commitInfo =
365 `${commit.sha.substring(0, 8)}: ${commit.message}\n` +
366 `Author: ${commit.author}, Date: ${commit.date}\n` +
367 `Stats: ${commit.stats.filesChanged} files changed, +${commit.stats.insertions} -${commit.stats.deletions}\n`
368
369 if (diffs.length > 0) {
370 commitInfo += `\nFile Changes:\n`
371 for (const diff of diffs) {
372 commitInfo += `\n--- ${diff.path} ---\n`
373
374 if (diff.preContent === '[NEW FILE]') {
375 commitInfo += `New file:\n${diff.postContent}\n`
376 } else if (diff.postContent === '[DELETED]') {
377 commitInfo += `File deleted\n`
378 } else {
379 // Show a simplified diff for existing files
380 const preLines = diff.preContent.split('\n')
381 const postLines = diff.postContent.split('\n')
382
383 let hasChanges = false
384 for (let i = 0; i < preLines.length; i++) {
385 if (preLines[i] !== postLines[i]) {
386 commitInfo += `Line ${i + 1}:\n- ${preLines[i]}\n+ ${postLines[i]}\n`
387 hasChanges = true
388 }
389 }
390
391 if (!hasChanges && preLines.length !== postLines.length) {
392 commitInfo += `File length changed from ${preLines.length} to ${postLines.length} lines\n`
393 }
394 }
395 }

Callers 1

pickCommitsFunction · 0.85

Calls 1

processCommitFunction · 0.70

Tested by

no test coverage detected