Commit 2f7aa72
committed
branchprotector: remove protection from excluded branches
Fix issue where excluded branches retain existing protection instead of being removed.
When a branch is added to the exclude list in branchprotector configuration, the tool
correctly stops applying new protection rules but does not remove existing protection
from branches that were previously protected.
This change adds logic to detect excluded branches that are currently protected and
queue them for removal by sending requirements with Request: nil, which triggers
RemoveBranchProtection() in the configureBranches() function.
The fix prevents push failures like:
remote: error: GH006: Protected branch update failed for refs/heads/konflux-branch
remote: - Changes must be made through a pull request.
Changes:
- Add detection logic for excluded protected branches in UpdateRepo()
- Send removal requests (Request: nil) for such branches
- Update tests to expect removal requests for excluded protected branches
- Add code comment explaining the call flow to RemoveBranchProtection
Fixes #4771 parent e2a3dbc commit 2f7aa72
2 files changed
+41
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
326 | 326 | | |
327 | 327 | | |
328 | 328 | | |
| 329 | + | |
329 | 330 | | |
330 | 331 | | |
331 | 332 | | |
332 | 333 | | |
333 | 334 | | |
| 335 | + | |
334 | 336 | | |
335 | 337 | | |
336 | 338 | | |
| |||
346 | 348 | | |
347 | 349 | | |
348 | 350 | | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
349 | 372 | | |
350 | 373 | | |
351 | 374 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1109 | 1109 | | |
1110 | 1110 | | |
1111 | 1111 | | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
1112 | 1118 | | |
1113 | 1119 | | |
1114 | 1120 | | |
| |||
1133 | 1139 | | |
1134 | 1140 | | |
1135 | 1141 | | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
1136 | 1154 | | |
1137 | 1155 | | |
1138 | 1156 | | |
| |||
0 commit comments