Skip to content

Commit b65c13c

Browse files
committed
Cleanup the PR
1 parent 0f81468 commit b65c13c

5 files changed

+53
-55
lines changed

group_iterations.go

+10-13
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@ import (
2626
// of the GitLab API
2727
//
2828
// GitLab API docs: https://docs.gitlab.com/ee/api/group_iterations.html
29-
3029
type GroupIterationsService struct {
3130
client *Client
3231
}
3332

3433
// GroupInteration represents a GitLab iteration.
3534
//
3635
// GitLab API docs: https://docs.gitlab.com/ee/api/group_iterations.html
37-
3836
type GroupIteration struct {
3937
ID int `json:"id"`
4038
IID int `json:"iid"`
@@ -54,22 +52,22 @@ func (i GroupIteration) String() string {
5452
return Stringify(i)
5553
}
5654

57-
// ListGroupIterationsOptions contains the available
58-
// ListGroupIterations() options
55+
// ListGroupIterationsOptions contains the available ListGroupIterations()
56+
// options
5957
//
60-
// GitLab API docs: https://docs.gitlab.com/ee/api/group_iterations.html#list-group-iterations
61-
58+
// GitLab API docs:
59+
// https://docs.gitlab.com/ee/api/group_iterations.html#list-group-iterations
6260
type ListGroupIterationsOptions struct {
6361
ListOptions
6462
State *string `url:"state,omitempty" json:"state,omitempty"`
6563
Search *string `url:"search,omitempty" json:"search,omitempty"`
6664
IncludeAncestors *bool `url:"include_ancestors,omitempty" json:"include_ancestors,omitempty"`
6765
}
6866

69-
// ListGroupIterations returns alist of group iterations.
67+
// ListGroupIterations returns a list of group iterations.
7068
//
71-
// GitLab API docs: https://docs.gitlab.com/ee/api/group_iterations.html#list-group-iterations
72-
69+
// GitLab API docs:
70+
// https://docs.gitlab.com/ee/api/group_iterations.html#list-group-iterations
7371
func (s *GroupIterationsService) ListGroupIterations(gid interface{}, opt *ListGroupIterationsOptions, options ...RequestOptionFunc) ([]*GroupIteration, *Response, error) {
7472
group, err := parseID(gid)
7573
if err != nil {
@@ -82,12 +80,11 @@ func (s *GroupIterationsService) ListGroupIterations(gid interface{}, opt *ListG
8280
return nil, nil, err
8381
}
8482

85-
var i []*GroupIteration
86-
resp, err := s.client.Do(req, &i)
83+
var gis []*GroupIteration
84+
resp, err := s.client.Do(req, &gis)
8785
if err != nil {
8886
return nil, nil, err
8987
}
9088

91-
return i, resp, err
92-
89+
return gis, resp, err
9390
}

group_iterations_test.go

+12-11
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@ func TestListGroupIterations(t *testing.T) {
1414
mux.HandleFunc("/api/v4/groups/5/iterations",
1515
func(w http.ResponseWriter, r *http.Request) {
1616
testMethod(t, r, http.MethodGet)
17-
fmt.Fprintf(w, `[{
18-
"id": 53,
19-
"iid": 13,
20-
"sequence": 1,
21-
"group_id": 5,
22-
"title": "Iteration II",
23-
"description": "Ipsum Lorem ipsum",
24-
"state": 2,
25-
"web_url": "http://gitlab.example.com/groups/my-group/-/iterations/13"
26-
}
27-
]`)
17+
fmt.Fprintf(w, `[
18+
{
19+
"id": 53,
20+
"iid": 13,
21+
"sequence": 1,
22+
"group_id": 5,
23+
"title": "Iteration II",
24+
"description": "Ipsum Lorem ipsum",
25+
"state": 2,
26+
"web_url": "http://gitlab.example.com/groups/my-group/-/iterations/13"
27+
}
28+
]`)
2829
})
2930

3031
iterations, _, err := client.GroupIterations.ListGroupIterations(5, &ListGroupIterationsOptions{})

project_iterations.go

+17-18
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,18 @@ import (
2222
"time"
2323
)
2424

25-
// IterationsAPI handles communication with the iterations related methods
26-
// of the GitLab API
25+
// IterationsAPI handles communication with the project iterations related
26+
// methods of the GitLab API
2727
//
2828
// GitLab API docs: https://docs.gitlab.com/ee/api/iterations.html
29-
3029
type ProjectIterationsService struct {
3130
client *Client
3231
}
3332

34-
// Iteration represents a GitLab iteration
33+
// ProjectIteration represents a GitLab project iteration.
3534
//
3635
// GitLab API docs: https://docs.gitlab.com/ee/api/iterations.html
37-
// CAVEAT: GitLab docu currently misses `sequence` key.
38-
type Iteration struct {
36+
type ProjectIteration struct {
3937
ID int `json:"id"`
4038
IID int `json:"iid"`
4139
Sequence int `json:"sequence"`
@@ -50,26 +48,27 @@ type Iteration struct {
5048
WebURL string `json:"web_url"`
5149
}
5250

53-
func (i Iteration) String() string {
51+
func (i ProjectIteration) String() string {
5452
return Stringify(i)
5553
}
5654

57-
// ListGroupIterationsOptions contains the available
58-
// ListGroupIterations() options
55+
// ListProjectIterationsOptions contains the available ListProjectIterations()
56+
// options
5957
//
60-
// GitLab API docs: https://docs.gitlab.com/ee/api/group_iterations.html#list-project-iterations
58+
// GitLab API docs:
59+
// https://docs.gitlab.com/ee/api/group_iterations.html#list-project-iterations
6160
type ListProjectIterationsOptions struct {
6261
ListOptions
6362
State *string `url:"state,omitempty" json:"state,omitempty"`
6463
Search *string `url:"search,omitempty" json:"search,omitempty"`
6564
IncludeAncestors *bool `url:"include_ancestors,omitempty" json:"include_ancestors,omitempty"`
6665
}
6766

68-
//ListProjectIterations lists all iterations of the projects ancestor groups.
69-
//As of GitLab 13.5, there are no direct project-level iterations.
70-
71-
// GitLab API docs: https://docs.gitlab.com/ee/api/iterations.html
72-
func (i *ProjectIterationsService) ListProjectIterations(pid interface{}, opt *ListProjectIterationsOptions, options ...RequestOptionFunc) ([]*Iteration, *Response, error) {
67+
// ListProjectIterations returns a list of projects iterations.
68+
//
69+
// GitLab API docs:
70+
// https://docs.gitlab.com/ee/api/group_iterations.html#list-project-iterations
71+
func (i *ProjectIterationsService) ListProjectIterations(pid interface{}, opt *ListProjectIterationsOptions, options ...RequestOptionFunc) ([]*ProjectIteration, *Response, error) {
7372
project, err := parseID(pid)
7473
if err != nil {
7574
return nil, nil, err
@@ -81,11 +80,11 @@ func (i *ProjectIterationsService) ListProjectIterations(pid interface{}, opt *L
8180
return nil, nil, err
8281
}
8382

84-
var it []*Iteration
85-
resp, err := i.client.Do(req, &it)
83+
var pis []*ProjectIteration
84+
resp, err := i.client.Do(req, &pis)
8685
if err != nil {
8786
return nil, resp, err
8887
}
8988

90-
return it, resp, err
89+
return pis, resp, err
9190
}

project_iterations_test.go

+13-12
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,26 @@ func TestListProjectIterations(t *testing.T) {
1414
mux.HandleFunc("/api/v4/projects/42/iterations",
1515
func(w http.ResponseWriter, r *http.Request) {
1616
testMethod(t, r, http.MethodGet)
17-
fmt.Fprintf(w, `[{
18-
"id": 53,
19-
"iid": 13,
20-
"sequence": 1,
21-
"group_id": 5,
22-
"title": "Iteration II",
23-
"description": "Ipsum Lorem ipsum",
24-
"state": 2,
25-
"web_url": "http://gitlab.example.com/groups/my-group/-/iterations/13"
26-
}
27-
]`)
17+
fmt.Fprintf(w, `[
18+
{
19+
"id": 53,
20+
"iid": 13,
21+
"sequence": 1,
22+
"group_id": 5,
23+
"title": "Iteration II",
24+
"description": "Ipsum Lorem ipsum",
25+
"state": 2,
26+
"web_url": "http://gitlab.example.com/groups/my-group/-/iterations/13"
27+
}
28+
]`)
2829
})
2930

3031
iterations, _, err := client.ProjectIterations.ListProjectIterations(42, &ListProjectIterationsOptions{})
3132
if err != nil {
3233
t.Errorf("GroupIterations.ListGroupIterations returned error: %v", err)
3334
}
3435

35-
want := []*Iteration{{
36+
want := []*ProjectIteration{{
3637
ID: 53,
3738
IID: 13,
3839
Sequence: 1,

testdata/list_group_iterations.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
"start_date": "2020-02-14",
1414
"web_url": "http://gitlab.example.com/groups/my-group/-/iterations/13"
1515
}
16-
]
16+
]

0 commit comments

Comments
 (0)