Skip to content

Commit 33958ec

Browse files
committed
chore: remove redundant fallback protection
1 parent e52720d commit 33958ec

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

src/git/github-provider.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,33 +1005,35 @@ export class GitHubProvider implements GitProvider {
10051005

10061006
console.log(`✅ Checked ${checkedCount} PRs via HTTP: ${openCount} open, ${checkedCount - openCount} closed`)
10071007
console.log(`🛡️ Protected ${protectedBranches.size} branches with confirmed open PRs`)
1008+
1009+
// Since HTTP detection was successful and is 100% accurate, we don't need fallback protection
1010+
console.log(`🎯 HTTP detection successful`)
10081011
}
10091012
catch (error) {
1010-
console.warn('⚠️ Could not check PR status via HTTP:', error)
1011-
}
1013+
console.warn('⚠️ Could not check PR status via HTTP, applying conservative fallback:', error)
10121014

1013-
// Method 2: Fallback protection for very recent branches (last 7 days)
1014-
// in case we missed any PRs or HTTP checks failed
1015-
try {
1016-
const allBuddyBranches = await this.getBuddyBotBranches()
1017-
const sevenDaysAgo = new Date()
1018-
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7)
1015+
// Only apply fallback protection if HTTP detection failed
1016+
try {
1017+
const allBuddyBranches = await this.getBuddyBotBranches()
1018+
const threeDaysAgo = new Date()
1019+
threeDaysAgo.setDate(threeDaysAgo.getDate() - 3)
1020+
1021+
let fallbackCount = 0
1022+
for (const branch of allBuddyBranches) {
1023+
if (branch.lastCommitDate > threeDaysAgo && !protectedBranches.has(branch.name)) {
1024+
protectedBranches.add(branch.name)
1025+
fallbackCount++
1026+
}
1027+
}
10191028

1020-
let fallbackCount = 0
1021-
for (const branch of allBuddyBranches) {
1022-
if (branch.lastCommitDate > sevenDaysAgo && !protectedBranches.has(branch.name)) {
1023-
protectedBranches.add(branch.name)
1024-
fallbackCount++
1029+
if (fallbackCount > 0) {
1030+
console.log(`🛡️ Fallback protection: ${fallbackCount} recent branches (< 3 days) protected due to HTTP failure`)
10251031
}
10261032
}
1027-
1028-
if (fallbackCount > 0) {
1029-
console.log(`🛡️ Fallback protection: ${fallbackCount} recent branches (< 7 days) also protected`)
1033+
catch {
1034+
console.log('⚠️ Could not apply fallback protection')
10301035
}
10311036
}
1032-
catch {
1033-
console.log('⚠️ Could not apply fallback protection')
1034-
}
10351037

10361038
console.log(`🎯 HTTP-based analysis complete: protecting ${protectedBranches.size} branches total`)
10371039

0 commit comments

Comments
 (0)