@@ -22,13 +22,13 @@ type LabelOption struct {
22
22
}
23
23
24
24
func (c * Client ) ListRepoLabels (owner , repo string ) ([]* Label , error ) {
25
- labels := make ([]* Label , 0 )
25
+ labels := make ([]* Label , 0 , 10 )
26
26
return labels , c .getParsedResponse ("GET" , fmt .Sprintf ("/repos/%s/%s/labels" , owner , repo ), nil , nil , & labels )
27
27
}
28
28
29
- func (c * Client ) GetRepoLabel (owner , repo string , index int64 ) (* Label , error ) {
29
+ func (c * Client ) GetRepoLabel (owner , repo string , id int64 ) (* Label , error ) {
30
30
label := new (Label )
31
- return label , c .getParsedResponse ("GET" , fmt .Sprintf ("/repos/%s/%s/labels/%d" , owner , repo , index ), nil , nil , label )
31
+ return label , c .getParsedResponse ("GET" , fmt .Sprintf ("/repos/%s/%s/labels/%d" , owner , repo , id ), nil , nil , label )
32
32
}
33
33
34
34
func (c * Client ) CreateLabel (owner , repo string , opt LabelOption ) (* Label , error ) {
@@ -41,18 +41,17 @@ func (c *Client) CreateLabel(owner, repo string, opt LabelOption) (*Label, error
41
41
jsonHeader , bytes .NewReader (body ), label )
42
42
}
43
43
44
- func (c * Client ) EditLabel (owner , repo string , index int64 , opt LabelOption ) (* Label , error ) {
44
+ func (c * Client ) EditLabel (owner , repo string , id int64 , opt LabelOption ) (* Label , error ) {
45
45
body , err := json .Marshal (& opt )
46
46
if err != nil {
47
47
return nil , err
48
48
}
49
49
label := new (Label )
50
- return label , c .getParsedResponse ("PATCH" , fmt .Sprintf ("/repos/%s/%s/labels/%d" , owner , repo , index ),
51
- jsonHeader , bytes .NewReader (body ), label )
50
+ return label , c .getParsedResponse ("PATCH" , fmt .Sprintf ("/repos/%s/%s/labels/%d" , owner , repo , id ), jsonHeader , bytes .NewReader (body ), label )
52
51
}
53
52
54
- func (c * Client ) DeleteLabel (owner , repo string , index int64 ) error {
55
- _ , err := c .getResponse ("DELETE" , fmt .Sprintf ("/repos/%s/%s/labels/%d" , owner , repo , index ), nil , nil )
53
+ func (c * Client ) DeleteLabel (owner , repo string , id int64 ) error {
54
+ _ , err := c .getResponse ("DELETE" , fmt .Sprintf ("/repos/%s/%s/labels/%d" , owner , repo , id ), nil , nil )
56
55
return err
57
56
}
58
57
@@ -61,7 +60,7 @@ type IssueLabelsOption struct {
61
60
}
62
61
63
62
func (c * Client ) GetIssueLabels (owner , repo string , index int64 ) ([]* Label , error ) {
64
- labels := make ([]* Label , 0 )
63
+ labels := make ([]* Label , 0 , 5 )
65
64
return labels , c .getParsedResponse ("GET" , fmt .Sprintf ("/repos/%s/%s/issues/%d/labels" , owner , repo , index ), nil , nil , & labels )
66
65
}
67
66
@@ -71,8 +70,7 @@ func (c *Client) AddIssueLabels(owner, repo string, index int64, opt IssueLabels
71
70
return nil , err
72
71
}
73
72
labels := make ([]* Label , 0 )
74
- return labels , c .getParsedResponse ("POST" , fmt .Sprintf ("/repos/%s/%s/issues/%d/labels" , owner , repo , index ),
75
- jsonHeader , bytes .NewReader (body ), & labels )
73
+ return labels , c .getParsedResponse ("POST" , fmt .Sprintf ("/repos/%s/%s/issues/%d/labels" , owner , repo , index ), jsonHeader , bytes .NewReader (body ), & labels )
76
74
}
77
75
78
76
func (c * Client ) ReplaceIssueLabels (owner , repo string , index int64 , opt IssueLabelsOption ) ([]* Label , error ) {
@@ -81,11 +79,10 @@ func (c *Client) ReplaceIssueLabels(owner, repo string, index int64, opt IssueLa
81
79
return nil , err
82
80
}
83
81
labels := make ([]* Label , 0 )
84
- return labels , c .getParsedResponse ("PUT" , fmt .Sprintf ("/repos/%s/%s/issues/%d/labels" , owner , repo , index ),
85
- jsonHeader , bytes .NewReader (body ), & labels )
82
+ return labels , c .getParsedResponse ("PUT" , fmt .Sprintf ("/repos/%s/%s/issues/%d/labels" , owner , repo , index ), jsonHeader , bytes .NewReader (body ), & labels )
86
83
}
87
84
88
- func (c * Client ) DeleteIssueLabel (owner , repo string , index int64 , label int64 ) error {
85
+ func (c * Client ) DeleteIssueLabel (owner , repo string , index , label int64 ) error {
89
86
_ , err := c .getResponse ("DELETE" , fmt .Sprintf ("/repos/%s/%s/issues/%d/labels/%d" , owner , repo , index , label ), nil , nil )
90
87
return err
91
88
}
0 commit comments