Skip to content

Commit 7b49058

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 88712b1 commit 7b49058

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

scripts/claude.mjs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3397,7 +3397,15 @@ Let's work through this together to get CI passing.`
33973397
currentSha = newShaResult.stdout.trim()
33983398
pushTime = Date.now()
33993399

3400-
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))
34013409
continue
34023410
}
34033411

@@ -3591,6 +3599,8 @@ Fix all issues by making necessary file changes. Be direct, don't ask questions.
35913599
},
35923600
)
35933601

3602+
let pushedNewCommit = false
3603+
35943604
if (fixStatusResult.stdout.trim()) {
35953605
log.progress('Committing CI fixes')
35963606

@@ -3638,14 +3648,28 @@ Fix all issues by making necessary file changes. Be direct, don't ask questions.
36383648
)
36393649
currentSha = newShaResult.stdout.trim()
36403650
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))
36413662
} else {
36423663
log.warn(
36433664
`Git commit failed: ${commitResult.stderr || commitResult.stdout}`,
36443665
)
36453666
}
36463667
}
36473668

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

0 commit comments

Comments
 (0)