MCPcopy Create free account
hub / github.com/gogs/gogs / ChangeMilestoneAssign

Function ChangeMilestoneAssign

internal/database/milestone.go:331–380  ·  view source on GitHub ↗

ChangeMilestoneAssign changes assignment of milestone for issue.

(doer *User, issue *Issue, oldMilestoneID int64)

Source from the content-addressed store, hash-verified

329
330// ChangeMilestoneAssign changes assignment of milestone for issue.
331func 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.
383func DeleteMilestoneOfRepoByID(repoID, id int64) error {

Callers 2

UpdateIssueMilestoneFunction · 0.92
EditIssueFunction · 0.92

Calls 6

changeMilestoneAssignFunction · 0.85
PrepareWebhooksFunction · 0.85
LoadIssueMethod · 0.80
APIFormatLegacyMethod · 0.80
ErrorMethod · 0.45
APIFormatMethod · 0.45

Tested by

no test coverage detected