also looking at this
fix: give GitLab/Bitbucket pipelines the review job, and stop cleanup lying
#1432
5 files
+152
-8
| @@ -1608,19 +1608,29 @@ export class GitHubProvider implements GitProvider { | ||
| 1608 | 1608 | this.logger.info(`✅ Deleted branch ${branchName} via git`) |
| 1609 | 1609 | } |
| 1610 | 1610 | 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. | |
| 1613 | 1613 | try { |
| 1614 | // Also delete local tracking branch if it exists | |
| 1615 | 1614 | await this.runCommand('git', ['branch', '-D', branchName]) |
| 1616 | this.logger.info(`✅ Deleted local branch ${branchName}`) | |
| 1617 | 1615 | } |
| 1618 | 1616 | catch { |
| 1619 | 1617 | // Ignore local deletion errors - branch might not exist locally |
| 1620 | 1618 | } |
| 1621 | 1619 | |
| 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 | ||
| 1622 | 1632 | this.logger.warn(`⚠️ Failed to delete remote branch ${branchName}: ${formatError(error)}`) |
| 1623 | // Don't throw - branch deletion failures are not critical | |
| 1633 | throw error | |
| 1624 | 1634 | } |
| 1625 | 1635 | } |
| 1626 | 1636 | |