summaryrefslogtreecommitdiffstats
path: root/models/issue_label.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/issue_label.go')
-rw-r--r--models/issue_label.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/models/issue_label.go b/models/issue_label.go
index 686897f63c..f378f62e65 100644
--- a/models/issue_label.go
+++ b/models/issue_label.go
@@ -127,6 +127,34 @@ func (label *Label) ForegroundColor() template.CSS {
return template.CSS("#000")
}
+func initalizeLabels(e Engine, repoID int64, labelTemplate string) error {
+ list, err := GetLabelTemplateFile(labelTemplate)
+ if err != nil {
+ return ErrIssueLabelTemplateLoad{labelTemplate, err}
+ }
+
+ labels := make([]*Label, len(list))
+ for i := 0; i < len(list); i++ {
+ labels[i] = &Label{
+ RepoID: repoID,
+ Name: list[i][0],
+ Description: list[i][2],
+ Color: list[i][1],
+ }
+ }
+ for _, label := range labels {
+ if err = newLabel(e, label); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+// InitalizeLabels adds a label set to a repository using a template
+func InitalizeLabels(repoID int64, labelTemplate string) error {
+ return initalizeLabels(x, repoID, labelTemplate)
+}
+
func newLabel(e Engine, label *Label) error {
_, err := e.Insert(label)
return err