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

Function UpdateIssueLabel

internal/route/repo/issue.go:743–778  ·  view source on GitHub ↗
(c *context.Context)

Source from the content-addressed store, hash-verified

741}
742
743func UpdateIssueLabel(c *context.Context) {
744 issue := getActionIssue(c)
745 if c.Written() {
746 return
747 }
748
749 if c.Query("action") == "clear" {
750 if err := issue.ClearLabels(c.User); err != nil {
751 c.Error(err, "clear labels")
752 return
753 }
754 } else {
755 isAttach := c.Query("action") == "attach"
756 label, err := database.GetLabelOfRepoByID(c.Repo.Repository.ID, c.QueryInt64("id"))
757 if err != nil {
758 c.NotFoundOrError(err, "get label by ID")
759 return
760 }
761
762 if isAttach && !issue.HasLabel(label.ID) {
763 if err = issue.AddLabel(c.User, label); err != nil {
764 c.Error(err, "add label")
765 return
766 }
767 } else if !isAttach && issue.HasLabel(label.ID) {
768 if err = issue.RemoveLabel(c.User, label); err != nil {
769 c.Error(err, "remove label")
770 return
771 }
772 }
773 }
774
775 c.JSONSuccess(map[string]any{
776 "ok": true,
777 })
778}
779
780func UpdateIssueMilestone(c *context.Context) {
781 issue := getActionIssue(c)

Callers

nothing calls this directly

Calls 9

GetLabelOfRepoByIDFunction · 0.92
getActionIssueFunction · 0.85
ClearLabelsMethod · 0.80
HasLabelMethod · 0.80
AddLabelMethod · 0.80
RemoveLabelMethod · 0.80
JSONSuccessMethod · 0.80
ErrorMethod · 0.45
NotFoundOrErrorMethod · 0.45

Tested by

no test coverage detected