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

Function InitializeLabels

internal/route/repo/issue.go:1009–1034  ·  view source on GitHub ↗
(c *context.Context, f form.InitializeLabels)

Source from the content-addressed store, hash-verified

1007}
1008
1009func InitializeLabels(c *context.Context, f form.InitializeLabels) {
1010 if c.HasError() {
1011 c.RawRedirect(c.Repo.MakeURL("labels"))
1012 return
1013 }
1014 list, err := database.GetLabelTemplateFile(f.TemplateName)
1015 if err != nil {
1016 c.Flash.Error(c.Tr("repo.issues.label_templates.fail_to_load_file", f.TemplateName, err))
1017 c.RawRedirect(c.Repo.MakeURL("labels"))
1018 return
1019 }
1020
1021 labels := make([]*database.Label, len(list))
1022 for i := 0; i < len(list); i++ {
1023 labels[i] = &database.Label{
1024 RepoID: c.Repo.Repository.ID,
1025 Name: list[i][0],
1026 Color: list[i][1],
1027 }
1028 }
1029 if err := database.NewLabels(labels...); err != nil {
1030 c.Error(err, "new labels")
1031 return
1032 }
1033 c.RawRedirect(c.Repo.MakeURL("labels"))
1034}
1035
1036func NewLabel(c *context.Context, f form.CreateLabel) {
1037 c.Data["Title"] = c.Tr("repo.labels")

Callers

nothing calls this directly

Calls 7

GetLabelTemplateFileFunction · 0.92
NewLabelsFunction · 0.92
HasErrorMethod · 0.80
RawRedirectMethod · 0.80
MakeURLMethod · 0.80
TrMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected