ReviewOS

also looking at this

stacks/buddy

fix: give GitLab/Bitbucket pipelines the review job, and stop cleanup lying

#1432
Merged glennmichael123 wants to merge fix/pipelines-and-cleanup into main
5 files +152 -8
src/git/github-provider.tsmodified+15-5
Changes to src/git/github-provider.ts
@@ -1608,19 +1608,29 @@ export class GitHubProvider implements GitProvider {
16081608 this.logger.info(`✅ Deleted branch ${branchName} via git`)
16091609 }
16101610 catch (error) {
1611 // If git push fails, it might be because the branch doesn't exist remotely
1612 // or we don't have push permissions. Try to delete locally and ignore errors.
1611 // The local tracking branch is tidied either way; it is not what the
1612 // caller asked about and its absence is not an error.
16131613 try {
1614 // Also delete local tracking branch if it exists
16151614 await this.runCommand('git', ['branch', '-D', branchName])
1616 this.logger.info(`✅ Deleted local branch ${branchName}`)
16171615 }
16181616 catch {
16191617 // Ignore local deletion errors - branch might not exist locally
16201618 }
16211619
1620 // A branch that is already gone is the outcome the caller wanted, so
1621 // that one failure is a success. Every other failure — no push
1622 // permission, network, protected branch — is reported by throwing, the
1623 // way the GitLab and Bitbucket providers already do. This used to
1624 // swallow all of them, which made `cleanupStaleBranches`'s `failed`
1625 // bucket unreachable: every branch was reported deleted whether the
1626 // push succeeded or not.
1627 if (/remote ref does not exist|unable to delete '[^']*': remote ref/i.test(formatError(error))) {
1628 this.logger.info(`ℹ️ Branch ${branchName} was already gone`)
1629 return
1630 }
1631
16221632 this.logger.warn(`⚠️ Failed to delete remote branch ${branchName}: ${formatError(error)}`)
1623 // Don't throw - branch deletion failures are not critical
1633 throw error
16241634 }
16251635 }
16261636