Skip to content

Commit 080e406

Browse files
committed
Migrate evals to use shallow git clones. Store parentSha per eval task
1 parent 845d906 commit 080e406

12 files changed

+65985
-257
lines changed

evals/git-evals/eval-codebuff.json

Lines changed: 27 additions & 14 deletions
Large diffs are not rendered by default.

evals/git-evals/eval-codebuff2.json

Lines changed: 124 additions & 62 deletions
Large diffs are not rendered by default.

evals/git-evals/eval-manifold.json

Lines changed: 41 additions & 21 deletions
Large diffs are not rendered by default.

evals/git-evals/eval-manifold2.json

Lines changed: 86 additions & 43 deletions
Large diffs are not rendered by default.

evals/git-evals/eval-plane.json

Lines changed: 71 additions & 36 deletions
Large diffs are not rendered by default.

evals/git-evals/eval-result-codebuff-yyzy-SZKdI4.json

Lines changed: 65448 additions & 0 deletions
Large diffs are not rendered by default.

evals/git-evals/eval-saleor.json

Lines changed: 71 additions & 36 deletions
Large diffs are not rendered by default.

evals/git-evals/gen-evals.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,43 @@ Please wrap your final specification in <spec></spec> tags.`
3030
const fingerprintId = 'evals-v2'
3131
const userInputId = 'evals-v2'
3232

33+
async function getParentSha(
34+
repoPath: string,
35+
commitSha: string,
36+
): Promise<string | null> {
37+
try {
38+
const parentSha = execSync(`git rev-parse ${commitSha}^`, {
39+
cwd: repoPath,
40+
encoding: 'utf-8',
41+
stdio: ['ignore', 'pipe', 'ignore'],
42+
}).trim()
43+
return parentSha
44+
} catch (error) {
45+
try {
46+
const parents = execSync(`git log --pretty=%P -n 1 ${commitSha}`, {
47+
cwd: repoPath,
48+
encoding: 'utf-8',
49+
stdio: ['ignore', 'pipe', 'ignore'],
50+
}).trim()
51+
const parentCount = parents.split(' ').filter(Boolean).length
52+
if (parentCount === 0) {
53+
console.warn(
54+
`Skipping ${commitSha.slice(0, 8)} - initial commit (no parent)`,
55+
)
56+
return null
57+
} else if (parentCount > 1) {
58+
console.warn(
59+
`Skipping ${commitSha.slice(0, 8)} - merge commit (${parentCount} parents)`,
60+
)
61+
return null
62+
}
63+
} catch (e) {
64+
console.error(`Error checking parents for ${commitSha.slice(0, 8)}:`, e)
65+
}
66+
return null
67+
}
68+
}
69+
3370
async function generateFileStateFromCommit(
3471
repoPath: string,
3572
commitSha: string,
@@ -191,6 +228,14 @@ export async function generateEvalFile({
191228
return null
192229
}
193230

231+
// Get parent SHA - either provided or computed from commit
232+
const parentSha =
233+
evalInput.parentSha ?? (await getParentSha(repoPath, evalInput.commitSha))
234+
235+
if (!parentSha) {
236+
return null
237+
}
238+
194239
// Get file states - either provided or computed from commit
195240
const fileStates =
196241
evalInput.fileStates ??
@@ -205,6 +250,7 @@ export async function generateEvalFile({
205250

206251
return {
207252
sha: evalInput.commitSha,
253+
parentSha,
208254
spec,
209255
fileStates,
210256
}

evals/git-evals/run-git-evals.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ export async function runSingleEval(
6969
process.on('unhandledRejection', unhandledHandler)
7070

7171
try {
72-
// Reset to the commit before the target commit
73-
resetRepoToCommit(projectPath, `${evalCommit.sha}^`)
72+
// Reset to the parent commit
73+
resetRepoToCommit(projectPath, evalCommit.parentSha)
7474

7575
// Initialize state
7676
let runner: Runner
@@ -221,7 +221,7 @@ Explain your reasoning in detail. Do not ask Codebuff to git commit changes.`,
221221
const endTime = new Date()
222222
const durationMs = endTime.getTime() - startTime.getTime()
223223

224-
const fileStates = getCodebuffFileStates(evalCommit.sha, projectPath)
224+
const fileStates = getCodebuffFileStates(evalCommit, projectPath)
225225

226226
if (fs.existsSync(projectPath) && fs.statSync(projectPath).isDirectory()) {
227227
fs.rmSync(projectPath, { recursive: true, force: true })
@@ -284,13 +284,12 @@ function writeJsonToFile(json: any, path: string) {
284284
}
285285

286286
function getCodebuffFileStates(
287-
evalCommitSha: string,
287+
evalCommit: EvalCommit,
288288
projectPath: string,
289289
): string {
290-
// Get all changes since the commit before the target commit
291290
execFileSync('git', ['add', '.'], { cwd: projectPath, stdio: 'ignore' })
292291

293-
return execFileSync('git', ['diff', `${evalCommitSha}^`], {
292+
return execFileSync('git', ['diff', evalCommit.parentSha], {
294293
cwd: projectPath,
295294
stdio: ['ignore', 'pipe', 'pipe'],
296295
}).toString()
@@ -453,6 +452,7 @@ export async function runGitEvals(
453452
evalCommit.sha,
454453
true,
455454
evalData.initCommand,
455+
evalCommit.parentSha,
456456
)
457457

458458
console.log(

evals/git-evals/run-single-eval.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ async function runSingleEvalTask(options: {
170170
evalCommit.sha,
171171
undefined,
172172
evalData.initCommand,
173+
evalCommit.parentSha,
173174
)
174175
console.log(`Repository cloned to: ${projectPath}`)
175176

0 commit comments

Comments
 (0)