(doer *User)
| 339 | } |
| 340 | |
| 341 | func (issue *Issue) ClearLabels(doer *User) (err error) { |
| 342 | sess := x.NewSession() |
| 343 | defer sess.Close() |
| 344 | if err = sess.Begin(); err != nil { |
| 345 | return err |
| 346 | } |
| 347 | |
| 348 | if err = issue.clearLabels(sess); err != nil { |
| 349 | return err |
| 350 | } |
| 351 | |
| 352 | if err = sess.Commit(); err != nil { |
| 353 | return errors.Newf("commit: %v", err) |
| 354 | } |
| 355 | |
| 356 | if issue.IsPull { |
| 357 | err = issue.PullRequest.LoadIssue() |
| 358 | if err != nil { |
| 359 | log.Error("LoadIssue: %v", err) |
| 360 | return err |
| 361 | } |
| 362 | err = PrepareWebhooks(issue.Repo, HookEventTypePullRequest, &api.PullRequestPayload{ |
| 363 | Action: api.HOOK_ISSUE_LABEL_CLEARED, |
| 364 | Index: issue.Index, |
| 365 | PullRequest: issue.PullRequest.APIFormat(), |
| 366 | Repository: issue.Repo.APIFormatLegacy(nil), |
| 367 | Sender: doer.APIFormat(), |
| 368 | }) |
| 369 | } else { |
| 370 | err = PrepareWebhooks(issue.Repo, HookEventTypeIssues, &api.IssuesPayload{ |
| 371 | Action: api.HOOK_ISSUE_LABEL_CLEARED, |
| 372 | Index: issue.Index, |
| 373 | Issue: issue.APIFormat(), |
| 374 | Repository: issue.Repo.APIFormatLegacy(nil), |
| 375 | Sender: doer.APIFormat(), |
| 376 | }) |
| 377 | } |
| 378 | if err != nil { |
| 379 | log.Error("PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err) |
| 380 | } |
| 381 | |
| 382 | return nil |
| 383 | } |
| 384 | |
| 385 | // ReplaceLabels removes all current labels and add new labels to the issue. |
| 386 | func (issue *Issue) ReplaceLabels(labels []*Label) (err error) { |
no test coverage detected