Skip to content

Commit d725743

Browse files
committed
#35 improve code structure
1 parent e3ad13b commit d725743

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
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.10.0"
17+
return "0.10.1"
1818
}
1919

2020
// Client represents a Gogs API client.

issue_label.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ type Label struct {
1616
Color string `json:"color"`
1717
}
1818

19-
type LabelOption struct {
20-
Name string `json:"name"`
21-
Color string `json:"color"`
22-
}
23-
2419
func (c *Client) ListRepoLabels(owner, repo string) ([]*Label, error) {
2520
labels := make([]*Label, 0, 10)
2621
return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels", owner, repo), nil, nil, &labels)
@@ -31,7 +26,12 @@ func (c *Client) GetRepoLabel(owner, repo string, id int64) (*Label, error) {
3126
return label, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, id), nil, nil, label)
3227
}
3328

34-
func (c *Client) CreateLabel(owner, repo string, opt LabelOption) (*Label, error) {
29+
type CreateLabelOption struct {
30+
Name string `json:"name" binding:"Required"`
31+
Color string `json:"color" binding:"Required;Size(7)"`
32+
}
33+
34+
func (c *Client) CreateLabel(owner, repo string, opt CreateLabelOption) (*Label, error) {
3535
body, err := json.Marshal(&opt)
3636
if err != nil {
3737
return nil, err
@@ -41,7 +41,12 @@ 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, id int64, opt LabelOption) (*Label, error) {
44+
type EditLabelOption struct {
45+
Name *string `json:"name"`
46+
Color *string `json:"color"`
47+
}
48+
49+
func (c *Client) EditLabel(owner, repo string, id int64, opt EditLabelOption) (*Label, error) {
4550
body, err := json.Marshal(&opt)
4651
if err != nil {
4752
return nil, err

0 commit comments

Comments
 (0)