@@ -19,22 +19,24 @@ import (
19
19
var labelColorPattern = regexp .MustCompile ("#([a-fA-F0-9]{6})" )
20
20
21
21
// GetLabelTemplateFile loads the label template file by given name,
22
- // then parses and returns a list of name-color pairs.
23
- func GetLabelTemplateFile (name string ) ([][2 ]string , error ) {
22
+ // then parses and returns a list of name-color pairs and optionally description .
23
+ func GetLabelTemplateFile (name string ) ([][3 ]string , error ) {
24
24
data , err := getRepoInitFile ("label" , name )
25
25
if err != nil {
26
26
return nil , fmt .Errorf ("getRepoInitFile: %v" , err )
27
27
}
28
28
29
29
lines := strings .Split (string (data ), "\n " )
30
- list := make ([][2 ]string , 0 , len (lines ))
30
+ list := make ([][3 ]string , 0 , len (lines ))
31
31
for i := 0 ; i < len (lines ); i ++ {
32
32
line := strings .TrimSpace (lines [i ])
33
33
if len (line ) == 0 {
34
34
continue
35
35
}
36
36
37
- fields := strings .SplitN (line , " " , 2 )
37
+ parts := strings .SplitN (line , ";" , 2 )
38
+
39
+ fields := strings .SplitN (parts [0 ], " " , 2 )
38
40
if len (fields ) != 2 {
39
41
return nil , fmt .Errorf ("line is malformed: %s" , line )
40
42
}
@@ -43,8 +45,14 @@ func GetLabelTemplateFile(name string) ([][2]string, error) {
43
45
return nil , fmt .Errorf ("bad HTML color code in line: %s" , line )
44
46
}
45
47
48
+ var description string
49
+
50
+ if len (parts ) > 1 {
51
+ description = strings .TrimSpace (parts [1 ])
52
+ }
53
+
46
54
fields [1 ] = strings .TrimSpace (fields [1 ])
47
- list = append (list , [2 ]string {fields [1 ], fields [0 ]})
55
+ list = append (list , [3 ]string {fields [1 ], fields [0 ], description })
48
56
}
49
57
50
58
return list , nil
@@ -55,6 +63,7 @@ type Label struct {
55
63
ID int64 `xorm:"pk autoincr"`
56
64
RepoID int64 `xorm:"INDEX"`
57
65
Name string
66
+ Description string
58
67
Color string `xorm:"VARCHAR(7)"`
59
68
NumIssues int
60
69
NumClosedIssues int
0 commit comments