Fix PR base branch update on merge conflicts#18
Conversation
513bb65 to
cb36bad
Compare
|
@codex review |
cb36bad to
4bf6fac
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if has_sibling_conflicts "$OLD_BASE" "$PR_BRANCH"; then | ||
| echo "⚠️ Keeping branch '$OLD_BASE' - still referenced by other conflicted PRs" | ||
| else | ||
| echo "Deleting old base branch '$OLD_BASE' (no other PRs depend on it)" | ||
| log_cmd git push origin ":$OLD_BASE" || echo "⚠️ Could not delete '$OLD_BASE' (may already be deleted)" |
There was a problem hiding this comment.
Avoid deleting whatever base the PR currently has
In continue_after_resolution, the branch deletion uses OLD_BASE that was derived from the PR’s current base earlier in the function. If a user resolves conflicts and manually updates the PR base to main/trunk (or any other branch) before the synchronize run, OLD_BASE will be that branch and this code will attempt git push origin :<branch>. On repos without protected branches, that can delete the default branch. Consider persisting the original merged branch from the conflict event (or guarding against deleting default/base branches or when NEW_TARGET is empty) rather than deleting the current base blindly.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
To use Codex here, create an environment for this repo.
When a merge conflict occurs during automatic PR stack update: - Don't change the PR's base branch (keeps the diff readable) - Don't delete the merged branch (user can reference it during resolution) After the user resolves conflicts and pushes: - Update the PR's base branch to trunk - Delete the old base branch only if no other conflicted PRs depend on it Changes: - main(): Track UPDATED_TARGETS vs CONFLICTED_TARGETS separately - main(): Only update base and delete branch for successfully updated PRs - Add has_sibling_conflicts() helper to check if other PRs share the base - continue_after_resolution(): Update base branch and conditionally delete - Update E2E tests to verify the new behavior - Add Scenario 3: sibling conflicts test for branch deletion timing
4bf6fac to
295018c
Compare
When a merge conflict occurs during automatic PR stack update:
After the user resolves conflicts and pushes:
Changes: