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

Method ClearLabels

internal/database/issue.go:341–383  ·  view source on GitHub ↗
(doer *User)

Source from the content-addressed store, hash-verified

339}
340
341func (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.
386func (issue *Issue) ReplaceLabels(labels []*Label) (err error) {

Callers 2

UpdateIssueLabelFunction · 0.80
ClearIssueLabelsFunction · 0.80

Implementers 1

mailerIssueinternal/database/issue_mail.go

Calls 6

clearLabelsMethod · 0.95
APIFormatMethod · 0.95
PrepareWebhooksFunction · 0.85
LoadIssueMethod · 0.80
APIFormatLegacyMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected