Skip to content

feat: implement issue #647 — dev-lead: rebase requested via @mention (on-mention intent) fails to push — non-fast-forward, no force-with-lease - #648

Closed
don-petry wants to merge 5 commits into
mainfrom
dev-lead/issue-647-20260613-1931
Closed

feat: implement issue #647 — dev-lead: rebase requested via @mention (on-mention intent) fails to push — non-fast-forward, no force-with-lease#648
don-petry wants to merge 5 commits into
mainfrom
dev-lead/issue-647-20260613-1931

Conversation

@don-petry

@don-petry don-petry commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

Closes #647

Implemented by dev-lead agent. Please review.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Auto-merge now detects when local branches diverge from upstream and retries failed pushes with force-with-lease
    • Protects against clobbering unseen remote changes during retry operations
    • Updates internal tracking state after successful force-push operations

…(on-mention intent) fails to push — non-fast-forward, no force-with-lease
@don-petry
don-petry requested a review from a team as a code owner June 13, 2026 19:36
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@github-actions[bot], we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 42 minutes and 54 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2379dc39-aab4-4636-9753-b09a1f4ca56f

📥 Commits

Reviewing files that changed from the base of the PR and between 394cdd6 and 8da214d.

📒 Files selected for processing (2)
  • scripts/lib/auto-merge.sh
  • tests/dev-lead/unit/test_auto_merge.bats
📝 Walkthrough

Walkthrough

The PR enhances push_with_merge_guard in the auto-merge script to handle push failures caused by branch history rewrites. A new divergence detector identifies when a branch is both ahead and behind upstream, then retries the push once with --force-with-lease. After successful retry, the tracked HEAD SHA is refreshed. Comprehensive tests verify the retry logic, boundary conditions, and state updates.

Changes

Divergence Detection and Force-with-Lease Retry for Rebased Branches

Layer / File(s) Summary
Divergence detection and force-with-lease retry mechanism
scripts/lib/auto-merge.sh, tests/dev-lead/unit/test_auto_merge.bats
push_with_merge_guard introduces _branch_diverged_from_upstream to detect rewritten history (branch both ahead and behind upstream), documents the new behavior, and implements one-time retry logic using --force-with-lease when divergence is detected. On successful retry, _AM_HEAD_SHA is refreshed to match the new HEAD. Comprehensive tests validate the retry behavior on diverged branches, absence of force-push on non-diverged or fast-forward-only cases, proper handling when no upstream exists, early exit for closed PRs, and correct state refresh.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • petry-projects/.github-private#453: Extended the same scripts/lib/auto-merge.sh with divergence detection and force-with-lease retry logic for rebased branches, including comprehensive unit tests for the new behavior.

Suggested labels

needs-human-review

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title clearly and concisely summarizes the main change: implementing detection and handling of non-fast-forward pushes via --force-with-lease in push_with_merge_guard to resolve issue #647.
Linked Issues check ✅ Passed The PR fully implements the preferred solution from issue #647: detecting branch divergence in push_with_merge_guard and retrying with --force-with-lease when local is both ahead and behind upstream.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the divergence detection and force-with-lease retry logic specified in issue #647; no extraneous modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev-lead/issue-647-20260613-1931

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a mechanism to retry a failed push with --force-with-lease when the local branch has diverged from its upstream (e.g., after a rebase), and adds comprehensive unit tests to verify this behavior. The feedback suggests optimizing the parsing of commit counts in _branch_diverged_from_upstream by using Bash's built-in read command instead of invoking awk multiple times.

Comment thread scripts/lib/auto-merge.sh Outdated
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — waiting on PR blockers (intent: review-changes)

PR: #648
No changes were committed, but the PR still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews). The retry cron will re-attempt automatically. Next attempt after: 2026-06-13T20:07:37Z

@don-petry

Copy link
Copy Markdown
Collaborator Author

Note

@don-petry I reviewed this PR and no code changes were needed, but it still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews), so I cannot mark it done yet. I'll re-check automatically.
Next attempt after: 2026-06-13T20:07:37Z

@don-petry
don-petry enabled auto-merge (squash) June 13, 2026 19:37
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 13, 2026
@don-petry
don-petry disabled auto-merge June 13, 2026 19:40
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — fix-reviews (applied)

Changes committed and pushed.

@sonarqubecloud

Copy link
Copy Markdown

@don-petry
don-petry disabled auto-merge June 13, 2026 19:43
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry
don-petry enabled auto-merge (squash) June 13, 2026 19:43

Copy link
Copy Markdown
Collaborator Author

Closing as a duplicate of #649, which already implements the --force-with-lease retry for rewritten-history pushes and has merged to main (closing #647). This PR implements the same fix, so it's now redundant. Thanks, dev-lead — the fix is in.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dev-lead: rebase requested via @mention (on-mention intent) fails to push — non-fast-forward, no force-with-lease

2 participants