Skip to content

Skip branch creation on PR saga retry#1455

Merged
adboio merged 2 commits intomainfrom
posthog-code/fix-code-issue-1443
Apr 2, 2026
Merged

Skip branch creation on PR saga retry#1455
adboio merged 2 commits intomainfrom
posthog-code/fix-code-issue-1443

Conversation

@adboio
Copy link
Copy Markdown
Contributor

@adboio adboio commented Apr 2, 2026

TL;DR

Prevent duplicate branch creation attempts when the PR saga is retried by checking if the target branch already exists before attempting to create it.

closes #1443

Problem

When the PR creation saga is retried, it was attempting to create a branch that may have already been created in the previous attempt, causing unnecessary operations and potential failures.

Changes

  • Added a check to compare the current branch against the target branch name before executing branch creation
  • Only create the branch if the current branch differs from the target branch name (indicating it hasn't been created yet)
  • On retry scenarios, the branch creation step is skipped since we're already on the desired branch
  • Refactored originalBranch variable to currentBranch for clarity since we check it at the start

How did you test this?

This is a defensive fix for the retry path in PR creation. The logic ensures that if a saga is retried after branch creation has already succeeded, we won't attempt to recreate the branch.

@adboio adboio marked this pull request as ready for review April 2, 2026 15:48
@adboio adboio requested a review from a team April 2, 2026 15:49
@adboio adboio merged commit 0a9a56f into main Apr 2, 2026
15 checks passed
@adboio adboio deleted the posthog-code/fix-code-issue-1443 branch April 2, 2026 16:00
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.

Branch recreation error

2 participants