ChangeMilestoneAssign changes assignment of milestone for issue.
(doer *User, issue *Issue, oldMilestoneID int64)
| 329 | |
| 330 | // ChangeMilestoneAssign changes assignment of milestone for issue. |
| 331 | func ChangeMilestoneAssign(doer *User, issue *Issue, oldMilestoneID int64) (err error) { |
| 332 | sess := x.NewSession() |
| 333 | defer sess.Close() |
| 334 | if err = sess.Begin(); err != nil { |
| 335 | return err |
| 336 | } |
| 337 | |
| 338 | if err = changeMilestoneAssign(sess, issue, oldMilestoneID); err != nil { |
| 339 | return err |
| 340 | } |
| 341 | |
| 342 | if err = sess.Commit(); err != nil { |
| 343 | return errors.Newf("commit: %v", err) |
| 344 | } |
| 345 | |
| 346 | var hookAction api.HookIssueAction |
| 347 | if issue.MilestoneID > 0 { |
| 348 | hookAction = api.HOOK_ISSUE_MILESTONED |
| 349 | } else { |
| 350 | hookAction = api.HOOK_ISSUE_DEMILESTONED |
| 351 | } |
| 352 | |
| 353 | if issue.IsPull { |
| 354 | err = issue.PullRequest.LoadIssue() |
| 355 | if err != nil { |
| 356 | log.Error("LoadIssue: %v", err) |
| 357 | return err |
| 358 | } |
| 359 | err = PrepareWebhooks(issue.Repo, HookEventTypePullRequest, &api.PullRequestPayload{ |
| 360 | Action: hookAction, |
| 361 | Index: issue.Index, |
| 362 | PullRequest: issue.PullRequest.APIFormat(), |
| 363 | Repository: issue.Repo.APIFormatLegacy(nil), |
| 364 | Sender: doer.APIFormat(), |
| 365 | }) |
| 366 | } else { |
| 367 | err = PrepareWebhooks(issue.Repo, HookEventTypeIssues, &api.IssuesPayload{ |
| 368 | Action: hookAction, |
| 369 | Index: issue.Index, |
| 370 | Issue: issue.APIFormat(), |
| 371 | Repository: issue.Repo.APIFormatLegacy(nil), |
| 372 | Sender: doer.APIFormat(), |
| 373 | }) |
| 374 | } |
| 375 | if err != nil { |
| 376 | log.Error("PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err) |
| 377 | } |
| 378 | |
| 379 | return nil |
| 380 | } |
| 381 | |
| 382 | // DeleteMilestoneOfRepoByID deletes a milestone from a repository. |
| 383 | func DeleteMilestoneOfRepoByID(repoID, id int64) error { |
no test coverage detected