Skip to content
This repository was archived by the owner on Jun 8, 2019. It is now read-only.

Commit 181ccc6

Browse files
committed
#35 code cleanup
1 parent 8431434 commit 181ccc6

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

gogs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
func Version() string {
17-
return "0.9.0"
17+
return "0.10.0"
1818
}
1919

2020
// Client represents a Gogs API client.

issue_label.go

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ type LabelOption struct {
2222
}
2323

2424
func (c *Client) ListRepoLabels(owner, repo string) ([]*Label, error) {
25-
labels := make([]*Label, 0)
25+
labels := make([]*Label, 0, 10)
2626
return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels", owner, repo), nil, nil, &labels)
2727
}
2828

29-
func (c *Client) GetRepoLabel(owner, repo string, index int64) (*Label, error) {
29+
func (c *Client) GetRepoLabel(owner, repo string, id int64) (*Label, error) {
3030
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)
3232
}
3333

3434
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
4141
jsonHeader, bytes.NewReader(body), label)
4242
}
4343

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) {
4545
body, err := json.Marshal(&opt)
4646
if err != nil {
4747
return nil, err
4848
}
4949
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)
5251
}
5352

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)
5655
return err
5756
}
5857

@@ -61,7 +60,7 @@ type IssueLabelsOption struct {
6160
}
6261

6362
func (c *Client) GetIssueLabels(owner, repo string, index int64) ([]*Label, error) {
64-
labels := make([]*Label, 0)
63+
labels := make([]*Label, 0, 5)
6564
return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index), nil, nil, &labels)
6665
}
6766

@@ -71,8 +70,7 @@ func (c *Client) AddIssueLabels(owner, repo string, index int64, opt IssueLabels
7170
return nil, err
7271
}
7372
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)
7674
}
7775

7876
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
8179
return nil, err
8280
}
8381
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)
8683
}
8784

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 {
8986
_, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/labels/%d", owner, repo, index, label), nil, nil)
9087
return err
9188
}

0 commit comments

Comments
 (0)