aboutsummaryrefslogtreecommitdiffstats
path: root/models/issue_label.go
diff options
context:
space:
mode:
authorOscar Costa <oscarcosta@gmail.com>2019-12-06 18:13:19 -0800
committertechknowlogick <techknowlogick@gitea.io>2019-12-06 21:13:19 -0500
commit1583c48e3a89fcb9aeb81a57295982ee64d5859f (patch)
tree00018c9c4ad684572b923d3750773fa12f0cd17a /models/issue_label.go
parenteba816e8269b6a4ad141da0d399a5613796a348e (diff)
downloadgitea-1583c48e3a89fcb9aeb81a57295982ee64d5859f.tar.gz
gitea-1583c48e3a89fcb9aeb81a57295982ee64d5859f.zip
Show label list on label set (#9251)
* Showing the list of labels of template files #7812 * Returning and logging errors when loading labels * Commenting public method * Change log level in case of error loading labels.
Diffstat (limited to 'models/issue_label.go')
-rw-r--r--models/issue_label.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/models/issue_label.go b/models/issue_label.go
index 4318406af7..1ea0ed85cc 100644
--- a/models/issue_label.go
+++ b/models/issue_label.go
@@ -132,6 +132,25 @@ func (label *Label) ForegroundColor() template.CSS {
return template.CSS("#000")
}
+func loadLabels(labelTemplate string) ([]string, error) {
+ list, err := GetLabelTemplateFile(labelTemplate)
+ if err != nil {
+ return nil, ErrIssueLabelTemplateLoad{labelTemplate, err}
+ }
+
+ labels := make([]string, len(list))
+ for i := 0; i < len(list); i++ {
+ labels[i] = list[i][0]
+ }
+ return labels, nil
+}
+
+// LoadLabelsFormatted loads the labels' list of a template file as a string separated by comma
+func LoadLabelsFormatted(labelTemplate string) (string, error) {
+ labels, err := loadLabels(labelTemplate)
+ return strings.Join(labels, ", "), err
+}
+
func initalizeLabels(e Engine, repoID int64, labelTemplate string) error {
list, err := GetLabelTemplateFile(labelTemplate)
if err != nil {