diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2018-05-21 10:28:29 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-21 10:28:29 +0800 |
commit | 6bdc556b7f490be7360104b731ce817050cc1d80 (patch) | |
tree | 63887addb45b5b2be1e672580c984497fa9f4112 /models/issue_user.go | |
parent | dc0ef38950ec8aca78f6e870fb83d1ca68074682 (diff) | |
download | gitea-6bdc556b7f490be7360104b731ce817050cc1d80.tar.gz gitea-6bdc556b7f490be7360104b731ce817050cc1d80.zip |
Fix some webhooks bugs (#3981)
* fix some webhooks bugs
* update vendor
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* fix test
* fix clearlabels
* fix pullrequest webhook bug fix #3492
* update release webhook description
* remove unused code
* fix push webhook in pull request
* small changes
Diffstat (limited to 'models/issue_user.go')
-rw-r--r-- | models/issue_user.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/models/issue_user.go b/models/issue_user.go index de5a185aec..733c35df1f 100644 --- a/models/issue_user.go +++ b/models/issue_user.go @@ -54,28 +54,30 @@ func newIssueUsers(e Engine, repo *Repository, issue *Issue) error { func updateIssueAssignee(e *xorm.Session, issue *Issue, assigneeID int64) (removed bool, err error) { // Check if the user exists - _, err = GetUserByID(assigneeID) + assignee, err := GetUserByID(assigneeID) if err != nil { return false, err } // Check if the submitted user is already assigne, if yes delete him otherwise add him - var toBeDeleted bool - for _, assignee := range issue.Assignees { - if assignee.ID == assigneeID { - toBeDeleted = true + var i int + for i = 0; i < len(issue.Assignees); i++ { + if issue.Assignees[i].ID == assigneeID { break } } assigneeIn := IssueAssignees{AssigneeID: assigneeID, IssueID: issue.ID} + toBeDeleted := i < len(issue.Assignees) if toBeDeleted { + issue.Assignees = append(issue.Assignees[:i], issue.Assignees[i:]...) _, err = e.Delete(assigneeIn) if err != nil { return toBeDeleted, err } } else { + issue.Assignees = append(issue.Assignees, assignee) _, err = e.Insert(assigneeIn) if err != nil { return toBeDeleted, err |