Skip to content

Commit

Permalink
fix issue with updating PR when the stack is reordered (aviator-co#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
wahyudibo committed Oct 23, 2024
1 parent 37c9124 commit 11aae61
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/gh/ghui/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const (
reasonPRIsClosed = "PR is closed."
reasonParentNotPushed = "Parent branch is not pushed to remote."
reasonNoPR = "Some branches in a stack do not have a PR."

ghErrorResponseNoNewCommits = "There are no new commits between base branch"
)

type pushCandidate struct {
Expand Down Expand Up @@ -101,6 +103,7 @@ type GitHubPushModel struct {
calculatingCandidates bool
askingForConfirmation bool
runningGitPush bool
reRunPRUpdate bool
done bool
}

Expand Down Expand Up @@ -274,6 +277,11 @@ func (vm *GitHubPushModel) runUpdate() (ret tea.Msg) {
if err := vm.runGitPush(); err != nil {
return err
}
if vm.reRunPRUpdate {
if err := vm.updatePRs(ghPRs); err != nil {
return err
}
}
return &GitHubPushProgress{gitPushDone: true}
}

Expand Down Expand Up @@ -370,6 +378,11 @@ func (vm *GitHubPushModel) updatePRs(ghPRs map[plumbing.ReferenceName]*gh.PullRe
BaseRefName: githubv4.NewString(githubv4.String(avbr.Parent.Name)),
Body: githubv4.NewString(githubv4.String(prBody)),
}); err != nil {
if strings.Contains(err.Error(), ghErrorResponseNoNewCommits) {
vm.reRunPRUpdate = true
continue
}

return err
}
}
Expand Down

0 comments on commit 11aae61

Please sign in to comment.