#35 code cleanup
This commit is contained in:
parent
84314343cb
commit
181ccc696c
2 changed files with 12 additions and 15 deletions
2
gogs.go
2
gogs.go
|
@ -14,7 +14,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func Version() string {
|
func Version() string {
|
||||||
return "0.9.0"
|
return "0.10.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client represents a Gogs API client.
|
// Client represents a Gogs API client.
|
||||||
|
|
|
@ -22,13 +22,13 @@ type LabelOption struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) ListRepoLabels(owner, repo string) ([]*Label, error) {
|
func (c *Client) ListRepoLabels(owner, repo string) ([]*Label, error) {
|
||||||
labels := make([]*Label, 0)
|
labels := make([]*Label, 0, 10)
|
||||||
return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels", owner, repo), nil, nil, &labels)
|
return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels", owner, repo), nil, nil, &labels)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) GetRepoLabel(owner, repo string, index int64) (*Label, error) {
|
func (c *Client) GetRepoLabel(owner, repo string, id int64) (*Label, error) {
|
||||||
label := new(Label)
|
label := new(Label)
|
||||||
return label, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, index), nil, nil, label)
|
return label, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, id), nil, nil, label)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) CreateLabel(owner, repo string, opt LabelOption) (*Label, error) {
|
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
|
||||||
jsonHeader, bytes.NewReader(body), label)
|
jsonHeader, bytes.NewReader(body), label)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) EditLabel(owner, repo string, index int64, opt LabelOption) (*Label, error) {
|
func (c *Client) EditLabel(owner, repo string, id int64, opt LabelOption) (*Label, error) {
|
||||||
body, err := json.Marshal(&opt)
|
body, err := json.Marshal(&opt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
label := new(Label)
|
label := new(Label)
|
||||||
return label, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, index),
|
return label, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, id), jsonHeader, bytes.NewReader(body), label)
|
||||||
jsonHeader, bytes.NewReader(body), label)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) DeleteLabel(owner, repo string, index int64) error {
|
func (c *Client) DeleteLabel(owner, repo string, id int64) error {
|
||||||
_, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, index), nil, nil)
|
_, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, id), nil, nil)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +60,7 @@ type IssueLabelsOption struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) GetIssueLabels(owner, repo string, index int64) ([]*Label, error) {
|
func (c *Client) GetIssueLabels(owner, repo string, index int64) ([]*Label, error) {
|
||||||
labels := make([]*Label, 0)
|
labels := make([]*Label, 0, 5)
|
||||||
return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index), nil, nil, &labels)
|
return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index), nil, nil, &labels)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,8 +70,7 @@ func (c *Client) AddIssueLabels(owner, repo string, index int64, opt IssueLabels
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
labels := make([]*Label, 0)
|
labels := make([]*Label, 0)
|
||||||
return labels, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index),
|
return labels, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index), jsonHeader, bytes.NewReader(body), &labels)
|
||||||
jsonHeader, bytes.NewReader(body), &labels)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) ReplaceIssueLabels(owner, repo string, index int64, opt IssueLabelsOption) ([]*Label, error) {
|
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
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
labels := make([]*Label, 0)
|
labels := make([]*Label, 0)
|
||||||
return labels, c.getParsedResponse("PUT", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index),
|
return labels, c.getParsedResponse("PUT", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index), jsonHeader, bytes.NewReader(body), &labels)
|
||||||
jsonHeader, bytes.NewReader(body), &labels)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) DeleteIssueLabel(owner, repo string, index int64, label int64) error {
|
func (c *Client) DeleteIssueLabel(owner, repo string, index, label int64) error {
|
||||||
_, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/labels/%d", owner, repo, index, label), nil, nil)
|
_, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/labels/%d", owner, repo, index, label), nil, nil)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue