Skip to content

Show how to restore the backport branch after deleting it - #196

Open
muhammad-a-dev wants to merge 1 commit into
python:mainfrom
muhammad-a-dev:restore-hint-after-delete
Open

muhammad-a-dev wants to merge 1 commit into
python:mainfrom
muhammad-a-dev:restore-hint-after-delete

Conversation

@muhammad-a-dev

Copy link
Copy Markdown

Fixes #78.

When cherry_picker deletes the backport branch (for example after a push that failed, as in the report in #78), any manual conflict resolution on that branch looks lost unless you know how to dig it out of git reflog.

This follows the suggestion in #78 (comment): cleanup_branch() now records the branch's commit before deleting it, and after a successful delete prints how to get it back:

branch backport-49cae39-3.10 has been deleted.
To restore it, run:
git branch backport-49cae39-3.10 <COMMIT_SHA>

If the commit can't be resolved, or the delete fails, nothing extra is printed. Nothing else changes about when the branch is deleted.

Tests: extended test_cleanup_branch to check the hint and the exact SHA, and test_cleanup_branch_fail to check no hint is printed when the delete fails. pytest (99 passed) and pre-commit run --all-files pass locally.

This change was prepared with the help of an AI assistant.

@StanFromIreland

Copy link
Copy Markdown
Member

IMO, this seems like a workaround for a problem we should fix instead. Skipping deletion when the push state is failed or letting the push failure propagate so the existing paused path handles it seem clearer to me.

@StanFromIreland

Copy link
Copy Markdown
Member

I wrote #197.

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.

Backport branch deleted even if push fails

2 participants