({
repoUrl,
commitShas,
outputPath,
}: {
repoUrl: string
commitShas: string[]
outputPath?: string
})
| 132 | } |
| 133 | |
| 134 | export 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, |
no test coverage detected