ReviewOS

also looking at this

stacks/buddy

fix(ci): land the lock-file repair instead of describing it

#1408
Merged glennmichael123 wants to merge fix/persist-the-mechanical-lockfile-repair into main
6 files +193 -15
bin/cli.tsmodified+21-2
Changes to bin/cli.ts
@@ -1374,8 +1374,10 @@ cli
13741374 baseBranch: config.repository?.baseBranch ?? 'main',
13751375 ai: createAiClient(config, logger),
13761376 logger,
1377 dryRun: Boolean(options.dryRun),
13771378 regenerateLockfile: async () => {
1378 const { regenerateLockFile, detectRequiredPackageManagers } = await import('../src/utils/lock-file')
1379 const { regenerateLockFile, detectRequiredPackageManagers, getAllLockFilePaths } = await import('../src/utils/lock-file')
1380 const { commitAndPush } = await import('../src/utils/git')
13791381
13801382 // Detection keys off the manifests a lockfile is derived from, so a
13811383 // repository with several ecosystems regenerates each of them.
@@ -1390,7 +1392,24 @@ cli
13901392 logger.warn(`⚠️ ${result.message}`)
13911393 }
13921394
1393 return regenerated
1395 if (!regenerated)
1396 return { regenerated: false, pushed: false }
1397
1398 // Rewriting the file in a workspace that is about to be thrown away
1399 // repairs nothing. The job checked this branch out with credentials,
1400 // so the commit is a local one rather than a branch recreation.
1401 try {
1402 const pushed = await commitAndPush(
1403 getAllLockFilePaths(),
1404 'fix(deps): regenerate the lock file\n\nThe lock file had drifted from the manifest, which failed CI.',
1405 process.cwd(),
1406 )
1407 return { regenerated: true, pushed }
1408 }
1409 catch (error) {
1410 logger.warn(`⚠️ Could not push the regenerated lock file: ${error instanceof Error ? error.message : String(error)}`)
1411 return { regenerated: true, pushed: false }
1412 }
13941413 },
13951414 })
13961415