Skip to content

Commit 3e50f22

Browse files
authored
Merge pull request #483 from spowelljr/fixPRTitleRace
Fix `/retitle` race condition
2 parents 59a573d + c058f70 commit 3e50f22

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

pkg/plugins/retitle/retitle.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func handleGenericCommentEvent(pc plugins.Agent, e github.GenericCommentEvent) e
9191
type githubClient interface {
9292
CreateComment(owner, repo string, number int, comment string) error
9393
GetPullRequest(org, repo string, number int) (*github.PullRequest, error)
94-
EditPullRequest(org, repo string, number int, pr *github.PullRequest) (*github.PullRequest, error)
94+
UpdatePullRequest(org, repo string, number int, title, body *string, open *bool, branch *string, canModify *bool) error
9595
GetIssue(org, repo string, number int) (*github.Issue, error)
9696
EditIssue(org, repo string, number int, issue *github.Issue) (*github.Issue, error)
9797
}
@@ -144,13 +144,7 @@ func handleGenericComment(gc githubClient, isTrusted func(string) (bool, error),
144144
}
145145

146146
if gce.IsPR {
147-
pr, err := gc.GetPullRequest(org, repo, number)
148-
if err != nil {
149-
return err
150-
}
151-
pr.Title = newTitle
152-
_, err = gc.EditPullRequest(org, repo, number, pr)
153-
return err
147+
return gc.UpdatePullRequest(org, repo, number, &newTitle, nil, nil, nil, nil)
154148
}
155149
issue, err := gc.GetIssue(org, repo, number)
156150
if err != nil {

0 commit comments

Comments
 (0)