Skip to content

Commit

Permalink
fix: fetch and checkout draft pr branch directly
Browse files Browse the repository at this point in the history
When the pull request is created in draft mode because of conflicts, the
suggestion did not fetch the branch of the opened draft pull request.
This meant that the instructions fail when switching, and the commits
are cherry-picked on the wrong branch.

Instead, we can fetch the branchname immediately. We no longer need to
fetch target either. And while we're at it, we can also simply checkout
the branch immediately, so we don't have to switch to it separately.
  • Loading branch information
korthout committed May 28, 2024
1 parent 7d390fd commit 863937d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/backport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,10 +614,9 @@ export class Backport {
if (branchExist) {
if (confictResolution === "draft_commit_conflicts") {
return dedent`\`\`\`bash
git fetch origin ${target}
git worktree add -d .worktree/${branchname} origin/${target}
git fetch origin ${branchname}
git worktree add --checkout .worktree/${branchname} origin/${target}
cd .worktree/${branchname}
git switch ${branchname}
git reset --hard HEAD^
git cherry-pick -x ${commitShasToCherryPick.join(" ")}
git push --force-with-lease
Expand Down

0 comments on commit 863937d

Please sign in to comment.