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

Function generateEvalFileV2

evals/buffbench/gen-evals.ts:134–261  ·  view source on GitHub ↗
({
  repoUrl,
  commitShas,
  outputPath,
}: {
  repoUrl: string
  commitShas: string[]
  outputPath?: string
})

Source from the content-addressed store, hash-verified

132}
133
134export async function generateEvalFileV2({
135 repoUrl,
136 commitShas,
137 outputPath,
138}: {
139 repoUrl: string
140 commitShas: string[]
141 outputPath?: string
142}): Promise<void> {
143 const actualRepoName = extractRepoNameFromUrl(repoUrl)
144
145 const client = new CodebuffClient({
146 apiKey: process.env[API_KEY_ENV_VAR] || getUserCredentials()?.authToken,
147 })
148
149 const finalOutputPath =
150 outputPath || path.join(__dirname, `eval-${actualRepoName}-v2.json`)
151 const partialOutputPath = finalOutputPath.replace(/\.json$/, '.partial.json')
152
153 console.log(`Processing ${commitShas.length} commits in parallel...`)
154 console.log(`Partial results will be saved to: ${partialOutputPath}`)
155 console.log(`Final results will be saved to: ${finalOutputPath}\n`)
156
157 const BATCH_SIZE = 5
158 const evalCommits: EvalCommitV2[] = []
159
160 const processCommit = async (
161 commitSha: string,
162 ): Promise<EvalCommitV2 | null> => {
163 console.log(`Processing commit ${commitSha.slice(0, 8)}...`)
164
165 return await withTestRepoAndParent(
166 {
167 repoUrl,
168 commitSha,
169 initCommand: undefined,
170 },
171 async (repoPath, commitSha, parentSha) => {
172 const fileDiffs = await extractFileDiffsFromCommit(
173 repoPath,
174 commitSha,
175 parentSha,
176 )
177
178 const fullDiff = getFullDiff(repoPath, commitSha, parentSha)
179 const commitMessage = getCommitMessage(repoPath, commitSha)
180 const editedFilePaths = fileDiffs.map((f) => f.path)
181
182 console.log(`Generating eval task for ${commitSha.slice(0, 8)}...`)
183 const taskResult = await generateEvalTask({
184 client,
185 input: {
186 commitSha,
187 parentSha,
188 diff: fullDiff,
189 editedFilePaths,
190 commitMessage,
191 repoPath,

Callers 2

generateRepoEvalV2Function · 0.90
gen-evals.tsFile · 0.85

Calls 4

extractRepoNameFromUrlFunction · 0.90
getUserCredentialsFunction · 0.90
savePartialResultsFunction · 0.85
processCommitFunction · 0.70

Tested by

no test coverage detected