fix: fix: hire-an-agent branch protection fails — race condition after initial push (#238) #245
No reviewers
Labels
No labels
action
backlog
blocked
bug-report
in-progress
prediction/actioned
prediction/dismissed
prediction/unreviewed
priority
tech-debt
underspecified
vision
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: disinto-admin/disinto#245
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/issue-238"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #238
Changes
AI Review
Summary
This PR adds a 3-attempt retry loop (2 s sleep between attempts) to the branch-existence check in
setup_vault_branch_protection,setup_profile_branch_protection, andsetup_project_branch_protection. The fix directly addresses a real race condition where Forgejo has not yet indexed a freshly-pushed branch by the time branch protection is applied.Review
lib/branch-protection.sh:59-74,252-267,438-453: Retry logic is sound. The loop runs up tomax_attempts=3, breaks immediately on HTTP 200, sleeps only between attempts (not after the last one), and incrementsattemptunconditionally — no off-by-one or infinite-loop risk.lib/branch-protection.sh:77,270,455: Updated to include attempt count, which aids debugging. Correct.set -euo pipefailis retained, variables are quoted,|| echo "0"fallback correctly handles curl failures, POSIX arithmetic used throughout. No ShellCheck concerns.Notes
The retry block is duplicated three times rather than extracted into a helper function. This is pre-existing tech debt (the single-check pattern was already duplicated before this PR), so it is not a blocker here.
Verdict
APPROVE — Correct retry logic applied consistently to all three branch-protection setup functions; fixes the race condition cleanly
Reviewed at
cbfbfef| AGENTS.mdAI Review: APPROVE — Correct retry logic applied consistently to all three branch-protection setup functions; fixes the race condition cleanly