Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cherry-pick aborting #480

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions miss_islington/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,7 @@ async def backport_task_asyncio(
""",
)
await util.assign_pr_to_core_dev(gh, issue_number, merged_by)
cp = cherry_picker.CherryPicker(
"origin",
commit_hash,
[branch],
config=CHERRY_PICKER_CONFIG,
prefix_commit=False,
)
cp = _get_cherry_picker(commit_hash, branch)
try:
cp.backport()
except cherry_picker.BranchCheckoutException:
Expand All @@ -120,6 +114,12 @@ async def backport_task_asyncio(
""",
)
await util.assign_pr_to_core_dev(gh, issue_number, merged_by)
# We need to set the state to BACKPORT_PAUSED so that CherryPicker allows us to
# abort it, switch back to the default branch, and clean up the backport branch
#
# Ideally, we would be able to do it in a less-hacky way but that will require some changes
# in the upstream, so for now this is probably the best we can do here.
cp.initial_state = cherry_picker.WORKFLOW_STATES.BACKPORT_PAUSED
cp.abort_cherry_pick()
except cherry_picker.CherryPickException:
await util.comment_on_pr(
Expand All @@ -133,9 +133,21 @@ async def backport_task_asyncio(
""",
)
await util.assign_pr_to_core_dev(gh, issue_number, merged_by)
# we need to get a new CherryPicker here to get an up-to-date (PAUSED) state
cp = _get_cherry_picker(commit_hash, branch)
cp.abort_cherry_pick()


def _get_cherry_picker(commit_hash, branch):
cp = cherry_picker.CherryPicker(
"origin",
commit_hash,
[branch],
config=CHERRY_PICKER_CONFIG,
prefix_commit=False,
)


class InitRepoStep(bootsteps.StartStopStep):
def start(self, c):
print("Initialize the repository.")
Expand Down