Skip to content

Commit ceef059

Browse files
committed
Avoid checking branches that have been checked
1 parent 4ed6711 commit ceef059

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/commands/fix/agent-fix.mts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ export async function agentFix(
218218
if (!packument) {
219219
logger.warn(`Unexpected condition: No packument found for ${name}.\n`)
220220
cleanupInfoEntriesLoop()
221+
// Skip to next package.
221222
continue infoEntriesLoop
222223
}
223224

@@ -268,8 +269,8 @@ export async function agentFix(
268269

269270
if (!oldVersions.length) {
270271
debugFn('notice', `skip: ${name} not found\n`)
271-
// Skip to next package.
272272
cleanupInfoEntriesLoop()
273+
// Skip to next package.
273274
continue infoEntriesLoop
274275
}
275276

@@ -279,6 +280,8 @@ export async function agentFix(
279280
const editablePkgJson = await readPackageJson(pkgJsonPath, {
280281
editable: true,
281282
})
283+
284+
const seenBranches = new Set<string>()
282285
const seenVersions = new Set<string>()
283286

284287
let hasAnnouncedWorkspace = false
@@ -324,13 +327,13 @@ export async function agentFix(
324327
continue infosLoop
325328
}
326329
const branch = getSocketBranchName(oldPurl, newVersion, workspace)
330+
if (seenBranches.has(newVersion)) {
331+
continue infosLoop
332+
}
327333
const pr = prs.find(p => p.headRefName === branch)
328334
if (pr) {
329335
debugFn('notice', `skip: PR #${pr.number} for ${name} exists`)
330-
if (++count >= limit) {
331-
cleanupInfoEntriesLoop()
332-
break infoEntriesLoop
333-
}
336+
seenBranches.add(branch)
334337
continue infosLoop
335338
}
336339
if (
@@ -339,10 +342,7 @@ export async function agentFix(
339342
(await gitRemoteBranchExists(branch, cwd))
340343
) {
341344
debugFn('notice', `skip: remote branch "${branch}" exists`)
342-
if (++count >= limit) {
343-
cleanupInfoEntriesLoop()
344-
break infoEntriesLoop
345-
}
345+
seenBranches.add(branch)
346346
continue infosLoop
347347
}
348348
const { overrides: oldOverrides } = getOverridesData(
@@ -500,6 +500,8 @@ export async function agentFix(
500500
return handleInstallFail()
501501
}
502502

503+
seenBranches.add(branch)
504+
503505
// eslint-disable-next-line no-await-in-loop
504506
await Promise.allSettled([
505507
setGitRemoteGithubRepoUrl(
@@ -613,6 +615,7 @@ export async function agentFix(
613615
debugFn('notice', 'increment: count', count + 1)
614616
if (++count >= limit) {
615617
cleanupInfoEntriesLoop()
618+
// Exit main loop.
616619
break infoEntriesLoop
617620
}
618621
}

0 commit comments

Comments
 (0)