Skip to content

[AINFRA-1406] Fix deletion of intermediate branch if nothing to backmerge#665

Merged
AliSoftware merged 2 commits intotrunkfrom
AINFRA-1406-fix-backmerge-action
Oct 14, 2025
Merged

[AINFRA-1406] Fix deletion of intermediate branch if nothing to backmerge#665
AliSoftware merged 2 commits intotrunkfrom
AINFRA-1406-fix-backmerge-action

Conversation

@AliSoftware
Copy link
Contributor

@AliSoftware AliSoftware commented Oct 13, 2025

What does it do?

Fixes the issue during create_release_backmerge_pull_request when there is nothing to backmerge but the automation already created the intermediate merge/… backmerge branch and is now trying to delete that branch to cancel the process and clean things up.

So far in that specific case we were still checked out on the merge/… intermediate when we were trying to delete that branch, but git doesn't allow to delete the current branch:


[!]     Error creating backmerge pull request:
--
  |  
  | ```
  | git '--git-dir=/opt/ci/builds/builder/automattic/day-one-ios/.git' '--work-tree=/opt/ci/builds/builder/automattic/day-one-ios' '-c' 'core.quotePath=true' '-c' 'color.ui=false' 'branch' '-D' 'merge/release-2025.21-into-trunk'  2>&1
  | status: pid 2243 exit 1
  | output: "error: cannot delete branch 'merge/release-2025.21-into-trunk' used by worktree at '/opt/ci/builds/builder/automattic/day-one-ios'\n"

The fix is to git checkout the previous branch (the head branch we were potentially trying to backmerge) before deleting the intermediate branch, so that we're sure we're not in the branch we're deleting.

Checklist before requesting a review

  • Run bundle exec rubocop to test for code style violations and recommendations.
  • Add Unit Tests (aka specs/*_spec.rb) if applicable.
  • Run bundle exec rspec to run the whole test suite and ensure all your tests pass.
  • Make sure you added an entry in the CHANGELOG.md file to describe your changes under the appropriate existing ### subsection of the existing ## Trunk section.
  • If applicable, add an entry in the MIGRATION.md file to describe how the changes will affect the migration from the previous major version and what the clients will need to change and consider.

@AliSoftware AliSoftware self-assigned this Oct 13, 2025
@AliSoftware AliSoftware requested a review from iangmaia October 13, 2025 14:53
@AliSoftware AliSoftware added the bug Something isn't working label Oct 13, 2025
Copy link
Contributor

@iangmaia iangmaia left a comment

Choose a reason for hiding this comment

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

👍

@AliSoftware AliSoftware merged commit 6a04dc9 into trunk Oct 14, 2025
8 checks passed
@AliSoftware AliSoftware deleted the AINFRA-1406-fix-backmerge-action branch October 14, 2025 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants