"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "models/issue_label.go" between
gitea-1.13.1.tar.gz and gitea-1.13.2.tar.gz

About: Gitea allows to set up a self-hosted code hosting Git service (a fork of Gogs).

issue_label.go  (gitea-1.13.1):issue_label.go  (gitea-1.13.2)
skipping to change at line 50 skipping to change at line 50
QueryString string `xorm:"-"` QueryString string `xorm:"-"`
IsSelected bool `xorm:"-"` IsSelected bool `xorm:"-"`
IsExcluded bool `xorm:"-"` IsExcluded bool `xorm:"-"`
} }
// GetLabelTemplateFile loads the label template file by given name, // GetLabelTemplateFile loads the label template file by given name,
// then parses and returns a list of name-color pairs and optionally description . // then parses and returns a list of name-color pairs and optionally description .
func GetLabelTemplateFile(name string) ([][3]string, error) { func GetLabelTemplateFile(name string) ([][3]string, error) {
data, err := GetRepoInitFile("label", name) data, err := GetRepoInitFile("label", name)
if err != nil { if err != nil {
return nil, fmt.Errorf("GetRepoInitFile: %v", err) return nil, ErrIssueLabelTemplateLoad{name, fmt.Errorf("GetRepoIn itFile: %v", err)}
} }
lines := strings.Split(string(data), "\n") lines := strings.Split(string(data), "\n")
list := make([][3]string, 0, len(lines)) list := make([][3]string, 0, len(lines))
for i := 0; i < len(lines); i++ { for i := 0; i < len(lines); i++ {
line := strings.TrimSpace(lines[i]) line := strings.TrimSpace(lines[i])
if len(line) == 0 { if len(line) == 0 {
continue continue
} }
parts := strings.SplitN(line, ";", 2) parts := strings.SplitN(line, ";", 2)
fields := strings.SplitN(parts[0], " ", 2) fields := strings.SplitN(parts[0], " ", 2)
if len(fields) != 2 { if len(fields) != 2 {
return nil, fmt.Errorf("line is malformed: %s", line) return nil, ErrIssueLabelTemplateLoad{name, fmt.Errorf("l ine is malformed: %s", line)}
} }
color := strings.Trim(fields[0], " ") color := strings.Trim(fields[0], " ")
if len(color) == 6 { if len(color) == 6 {
color = "#" + color color = "#" + color
} }
if !LabelColorPattern.MatchString(color) { if !LabelColorPattern.MatchString(color) {
return nil, fmt.Errorf("bad HTML color code in line: %s", line) return nil, ErrIssueLabelTemplateLoad{name, fmt.Errorf("b ad HTML color code in line: %s", line)}
} }
var description string var description string
if len(parts) > 1 { if len(parts) > 1 {
description = strings.TrimSpace(parts[1]) description = strings.TrimSpace(parts[1])
} }
fields[1] = strings.TrimSpace(fields[1]) fields[1] = strings.TrimSpace(fields[1])
list = append(list, [3]string{fields[1], color, description}) list = append(list, [3]string{fields[1], color, description})
skipping to change at line 170 skipping to change at line 170
// .____ ___. .__ // .____ ___. .__
// | | _____ \_ |__ ____ | | // | | _____ \_ |__ ____ | |
// | | \__ \ | __ \_/ __ \| | // | | \__ \ | __ \_/ __ \| |
// | |___ / __ \| \_\ \ ___/| |__ // | |___ / __ \| \_\ \ ___/| |__
// >_______ (____ /___ /\___ >____/ // >_______ (____ /___ /\___ >____/
func loadLabels(labelTemplate string) ([]string, error) { func loadLabels(labelTemplate string) ([]string, error) {
list, err := GetLabelTemplateFile(labelTemplate) list, err := GetLabelTemplateFile(labelTemplate)
if err != nil { if err != nil {
return nil, ErrIssueLabelTemplateLoad{labelTemplate, err} return nil, err
} }
labels := make([]string, len(list)) labels := make([]string, len(list))
for i := 0; i < len(list); i++ { for i := 0; i < len(list); i++ {
labels[i] = list[i][0] labels[i] = list[i][0]
} }
return labels, nil return labels, nil
} }
// LoadLabelsFormatted loads the labels' list of a template file as a string sep arated by comma // LoadLabelsFormatted loads the labels' list of a template file as a string sep arated by comma
func LoadLabelsFormatted(labelTemplate string) (string, error) { func LoadLabelsFormatted(labelTemplate string) (string, error) {
labels, err := loadLabels(labelTemplate) labels, err := loadLabels(labelTemplate)
return strings.Join(labels, ", "), err return strings.Join(labels, ", "), err
} }
func initializeLabels(e Engine, id int64, labelTemplate string, isOrg bool) erro r { func initializeLabels(e Engine, id int64, labelTemplate string, isOrg bool) erro r {
list, err := GetLabelTemplateFile(labelTemplate) list, err := GetLabelTemplateFile(labelTemplate)
if err != nil { if err != nil {
return ErrIssueLabelTemplateLoad{labelTemplate, err} return err
} }
labels := make([]*Label, len(list)) labels := make([]*Label, len(list))
for i := 0; i < len(list); i++ { for i := 0; i < len(list); i++ {
labels[i] = &Label{ labels[i] = &Label{
Name: list[i][0], Name: list[i][0],
Description: list[i][2], Description: list[i][2],
Color: list[i][1], Color: list[i][1],
} }
if isOrg { if isOrg {
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)