Skip to content

fix: clean skips already merged or closed PRs and reports why a close failed - #151

Merged
vitali87 merged 5 commits into
mainfrom
fix/clean-skips-merged-prs
Aug 31, 2026
Merged

fix: clean skips already merged or closed PRs and reports why a close failed#151
vitali87 merged 5 commits into
mainfrom
fix/clean-skips-merged-prs

Conversation

@vitali87

Copy link
Copy Markdown
Owner

Summary

After pr-split merge, running pr-split clean warned Could not close PR #N for every merged PR — gh pr close refuses a merged PR — and dropped the reason; an already-closed PR (gh exits 0) was counted as newly closed. With #55's completeness check that also meant a fully merged split could never remove its plan file.

_cleanup_git_state now asks get_pr_state first: MERGED/CLOSED PRs log PR #N is already merged, nothing to close, are not closed again, and count as done; a real close failure logs Could not close PR #N: <reason>. An unknown state (fetch error) still attempts the close so the real error reaches the user.

Stacked on #55 (fix/reliable-branch-cleanup).

Test plan

  • TestCleanupSkipsFinishedPrs: merged + closed + open trio → only the open one is closed, no warnings, plan removed; a close failure keeps the plan and includes the reason — both fail on the base
  • existing cleanup tests now stub get_pr_state as OPEN
  • 450 tests pass, ruff clean
  • Local review: 5/5

Noted by the review, not in this PR: after merge --delete-branch the branch half of #55's completeness check has the same "already gone" problem.

@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 18 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bd90301a-aadb-4268-ab15-229a97434698

📥 Commits

Reviewing files that changed from the base of the PR and between 42c1181 and dd753f7.

📒 Files selected for processing (3)
  • pr_split/cli.py
  • pr_split/logs.py
  • tests/test_cli_new_features.py

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.

@vitali87
vitali87 force-pushed the fix/clean-skips-merged-prs branch from f83ef7d to 61fd281 Compare August 30, 2026 19:24
Base automatically changed from fix/reliable-branch-cleanup to main August 31, 2026 01:25
@vitali87
vitali87 merged commit b0de942 into main Aug 31, 2026
4 checks passed
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.

1 participant