From 5576369041e6eb52a2c464a02877416044d52205 Mon Sep 17 00:00:00 2001 From: SagePtr Date: Thu, 16 Aug 2018 13:52:51 +0200 Subject: [PATCH] Fix failure on creating pull request with assignees (#4419) --- models/issue.go | 2 +- models/issue_assignees.go | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/models/issue.go b/models/issue.go index 99f379f585d5b..c9f8a2184756f 100644 --- a/models/issue.go +++ b/models/issue.go @@ -950,7 +950,7 @@ func newIssue(e *xorm.Session, doer *User, opts NewIssueOptions) (err error) { // Insert the assignees for _, assigneeID := range opts.AssigneeIDs { - err = opts.Issue.changeAssignee(e, doer, assigneeID) + err = opts.Issue.changeAssignee(e, doer, assigneeID, true) if err != nil { return err } diff --git a/models/issue_assignees.go b/models/issue_assignees.go index 24773cc5764db..b4f346974b311 100644 --- a/models/issue_assignees.go +++ b/models/issue_assignees.go @@ -134,14 +134,14 @@ func (issue *Issue) ChangeAssignee(doer *User, assigneeID int64) (err error) { return err } - if err := issue.changeAssignee(sess, doer, assigneeID); err != nil { + if err := issue.changeAssignee(sess, doer, assigneeID, false); err != nil { return err } return sess.Commit() } -func (issue *Issue) changeAssignee(sess *xorm.Session, doer *User, assigneeID int64) (err error) { +func (issue *Issue) changeAssignee(sess *xorm.Session, doer *User, assigneeID int64, isCreate bool) (err error) { // Update the assignee removed, err := updateIssueAssignee(sess, issue, assigneeID) @@ -161,6 +161,10 @@ func (issue *Issue) changeAssignee(sess *xorm.Session, doer *User, assigneeID in mode, _ := accessLevel(sess, doer.ID, issue.Repo) if issue.IsPull { + // if pull request is in the middle of creation - don't call webhook + if isCreate { + return nil + } if err = issue.loadPullRequest(sess); err != nil { return fmt.Errorf("loadPullRequest: %v", err) }