Skip to content

Commit cdfad4c

Browse files
committed
#39 code clean up
1 parent 82d9ef4 commit cdfad4c

File tree

2 files changed

+17
-52
lines changed

2 files changed

+17
-52
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.12.1"
17+
return "0.12.2"
1818
}
1919

2020
// Client represents a Gogs API client.

issue_milestone.go

Lines changed: 16 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -13,49 +13,45 @@ import (
1313

1414
type Milestone struct {
1515
ID int64 `json:"id"`
16-
State StateType `json:"state"`
1716
Title string `json:"title"`
1817
Description string `json:"description"`
18+
State StateType `json:"state"`
1919
OpenIssues int `json:"open_issues"`
2020
ClosedIssues int `json:"closed_issues"`
2121
Closed *time.Time `json:"closed_at"`
2222
Deadline *time.Time `json:"due_on"`
2323
}
2424

25-
type CreateMilestoneOption struct {
26-
Title string `json:"title"`
27-
Description string `json:"description"`
28-
Deadline *time.Time `json:"due_on"`
29-
}
30-
31-
type EditMilestoneOption struct {
32-
Title string `json:"title"`
33-
Description string `json:"description"`
34-
Deadline *time.Time `json:"due_on"`
35-
}
36-
37-
type SetIssueMilestoneOption struct {
38-
ID int64 `json:"id"`
39-
}
40-
4125
func (c *Client) ListRepoMilestones(owner, repo string) ([]*Milestone, error) {
4226
milestones := make([]*Milestone, 0, 10)
4327
return milestones, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/milestones", owner, repo), nil, nil, &milestones)
4428
}
4529

46-
func (c *Client) GetRepoMilestone(owner, repo string, id int64) (*Milestone, error) {
30+
func (c *Client) GetMilestone(owner, repo string, id int64) (*Milestone, error) {
4731
milestone := new(Milestone)
4832
return milestone, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), nil, nil, milestone)
4933
}
5034

35+
type CreateMilestoneOption struct {
36+
Title string `json:"title"`
37+
Description string `json:"description"`
38+
Deadline *time.Time `json:"due_on"`
39+
}
40+
5141
func (c *Client) CreateMilestone(owner, repo string, opt CreateMilestoneOption) (*Milestone, error) {
5242
body, err := json.Marshal(&opt)
5343
if err != nil {
5444
return nil, err
5545
}
5646
milestone := new(Milestone)
57-
return milestone, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/milestones", owner, repo),
58-
jsonHeader, bytes.NewReader(body), milestone)
47+
return milestone, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/milestones", owner, repo), jsonHeader, bytes.NewReader(body), milestone)
48+
}
49+
50+
type EditMilestoneOption struct {
51+
Title *string `json:"title"`
52+
Description *string `json:"description"`
53+
State *string `json:"state"`
54+
Deadline *time.Time `json:"due_on"`
5955
}
6056

6157
func (c *Client) EditMilestone(owner, repo string, id int64, opt EditMilestoneOption) (*Milestone, error) {
@@ -71,34 +67,3 @@ func (c *Client) DeleteMilestone(owner, repo string, id int64) error {
7167
_, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), nil, nil)
7268
return err
7369
}
74-
75-
func (c *Client) ChangeMilestoneStatus(owner, repo string, id int64, open bool) (*Milestone, error) {
76-
var action string
77-
if open {
78-
action = "open"
79-
} else {
80-
action = "close"
81-
}
82-
83-
milestone := new(Milestone)
84-
return milestone, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/milestones/%d/%s", owner, repo, id, action), nil, nil, milestone)
85-
}
86-
87-
func (c *Client) GetIssueMilestone(owner, repo string, index int64) (*Milestone, error) {
88-
milestone := new(Milestone)
89-
return milestone, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/milestone", owner, repo, index), nil, nil, &milestone)
90-
}
91-
92-
func (c *Client) SetIssueMilestone(owner, repo string, index int64, opt SetIssueMilestoneOption) (*Milestone, error) {
93-
body, err := json.Marshal(&opt)
94-
if err != nil {
95-
return nil, err
96-
}
97-
milestone := new(Milestone)
98-
return milestone, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/milestone", owner, repo, index), jsonHeader, bytes.NewReader(body), &milestone)
99-
}
100-
101-
func (c *Client) DeleteIssueMilestone(owner, repo string, index int64) error {
102-
_, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/milestone", owner, repo, index), nil, nil)
103-
return err
104-
}

0 commit comments

Comments
 (0)