Skip to content

Commit e67ce26

Browse files
committed
Fix --green retry counter reset after pushing new commits
When --green pushes a fix commit, it should reset the retry counter to 0 since it's a new commit that deserves its own set of retry attempts. Previous behavior: - Attempt 1: Check commit A, fail, fix, push commit B, retryCount = 1 - Attempt 2: Check commit B, fail, fix, push commit C, retryCount = 2 - Attempt 3: Check commit C, fail, give up (retryCount >= maxRetries-1) Fixed behavior: - Attempt 1: Check commit A, fail, fix, push commit B, retryCount = 0 - Attempt 1: Check commit B, fail, fix, push commit C, retryCount = 0 - Attempt 1: Check commit C, fail, fix, push commit D, retryCount = 0 - (continues with proper retry attempts for each new commit) Also adds 15-second wait after pushing to allow new CI run to start.
1 parent dbe3b31 commit e67ce26

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

scripts/claude.mjs

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import { spawn } from 'node:child_process'
88
import { existsSync, promises as fs } from 'node:fs'
99
import path from 'node:path'
1010
import { fileURLToPath } from 'node:url'
11-
import { parseArgs } from '@socketsecurity/lib/argv/parse'
11+
1212
import colors from 'yoctocolors-cjs'
1313

14+
import { parseArgs } from '@socketsecurity/lib/argv/parse'
15+
1416
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1517
const rootPath = path.join(__dirname, '..')
1618
const parentPath = path.join(rootPath, '..')
@@ -3395,7 +3397,15 @@ Let's work through this together to get CI passing.`
33953397
currentSha = newShaResult.stdout.trim()
33963398
pushTime = Date.now()
33973399

3398-
retryCount++
3400+
// Reset retry count for new commit - it deserves its own attempts
3401+
log.substep(
3402+
`New commit ${currentSha.substring(0, 7)}, resetting retry counter`,
3403+
)
3404+
retryCount = 0
3405+
3406+
// Wait for new CI run to start
3407+
log.substep('Waiting 15 seconds for new CI run to start...')
3408+
await new Promise(resolve => setTimeout(resolve, 15_000))
33993409
continue
34003410
}
34013411

@@ -3589,6 +3599,8 @@ Fix all issues by making necessary file changes. Be direct, don't ask questions.
35893599
},
35903600
)
35913601

3602+
let pushedNewCommit = false
3603+
35923604
if (fixStatusResult.stdout.trim()) {
35933605
log.progress('Committing CI fixes')
35943606

@@ -3636,14 +3648,28 @@ Fix all issues by making necessary file changes. Be direct, don't ask questions.
36363648
)
36373649
currentSha = newShaResult.stdout.trim()
36383650
pushTime = Date.now()
3651+
pushedNewCommit = true
3652+
3653+
// Reset retry count for new commit - it deserves its own attempts
3654+
log.substep(
3655+
`New commit ${currentSha.substring(0, 7)}, resetting retry counter`,
3656+
)
3657+
retryCount = 0
3658+
3659+
// Wait for new CI run to start
3660+
log.substep('Waiting 15 seconds for new CI run to start...')
3661+
await new Promise(resolve => setTimeout(resolve, 15_000))
36393662
} else {
36403663
log.warn(
36413664
`Git commit failed: ${commitResult.stderr || commitResult.stdout}`,
36423665
)
36433666
}
36443667
}
36453668

3646-
retryCount++
3669+
// Only increment retry count if we didn't push a new commit
3670+
if (!pushedNewCommit) {
3671+
retryCount++
3672+
}
36473673
} else {
36483674
log.error(`CI still failing after ${maxRetries} attempts`)
36493675
log.substep(

0 commit comments

Comments
 (0)