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 issue with updating PR when the stack is reordered (#395) #436

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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