Skip to content

Commit 863937d

Browse files
committed
fix: fetch and checkout draft pr branch directly
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.
1 parent 7d390fd commit 863937d

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

src/backport.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,10 +614,9 @@ export class Backport {
614614
if (branchExist) {
615615
if (confictResolution === "draft_commit_conflicts") {
616616
return dedent`\`\`\`bash
617-
git fetch origin ${target}
618-
git worktree add -d .worktree/${branchname} origin/${target}
617+
git fetch origin ${branchname}
618+
git worktree add --checkout .worktree/${branchname} origin/${target}
619619
cd .worktree/${branchname}
620-
git switch ${branchname}
621620
git reset --hard HEAD^
622621
git cherry-pick -x ${commitShasToCherryPick.join(" ")}
623622
git push --force-with-lease

0 commit comments

Comments
 (0)