From 0bc563011aa5acff2b91066001a0aae74b42671c Mon Sep 17 00:00:00 2001 From: Michael Dorner Date: Fri, 13 Apr 2018 11:41:38 +0200 Subject: [PATCH 1/7] changed all occurrences of the `S` parameter according to the Gerrit API ("The `S` or `start` query parameter can be supplied to skip a number of changes from the list.") --- changes.go | 1 - projects.go | 2 +- projects_branch.go | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/changes.go b/changes.go index d7da52d..e7e1c04 100644 --- a/changes.go +++ b/changes.go @@ -366,7 +366,6 @@ type QueryChangeOptions struct { // The S or start query parameter can be supplied to skip a number of changes from the list. Skip int `url:"S,omitempty"` - Start int `url:"start,omitempty"` ChangeOptions } diff --git a/projects.go b/projects.go index 5695c6b..f2c0bd1 100644 --- a/projects.go +++ b/projects.go @@ -171,7 +171,7 @@ type ProjectBaseOptions struct { Limit int `url:"n,omitempty"` // Skip the given number of branches from the beginning of the list. - Skip string `url:"s,omitempty"` + Skip string `url:"S,omitempty"` } // ProjectOptions specifies the parameters to the ProjectsService.ListProjects. diff --git a/projects_branch.go b/projects_branch.go index 66d8ba8..6fe3de9 100644 --- a/projects_branch.go +++ b/projects_branch.go @@ -32,7 +32,7 @@ type BranchOptions struct { Limit int `url:"n,omitempty"` // Skip the given number of branches from the beginning of the list. - Skip string `url:"s,omitempty"` + Skip string `url:"S,omitempty"` // Substring limits the results to those projects that match the specified substring. Substring string `url:"m,omitempty"` From 1f36d59063a1c82c799e9b1e833c8697a6f2c35e Mon Sep 17 00:00:00 2001 From: Michael Dorner Date: Fri, 13 Apr 2018 11:49:47 +0200 Subject: [PATCH 2/7] fixed format issue --- changes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes.go b/changes.go index e7e1c04..e26a077 100644 --- a/changes.go +++ b/changes.go @@ -365,7 +365,7 @@ type QueryChangeOptions struct { QueryOptions // The S or start query parameter can be supplied to skip a number of changes from the list. - Skip int `url:"S,omitempty"` + Skip int `url:"S,omitempty"` ChangeOptions } From a47fe1b723310a01b8db2b078736233cd48df38a Mon Sep 17 00:00:00 2001 From: Michael Dorner Date: Sun, 10 May 2020 14:16:15 +0200 Subject: [PATCH 3/7] added change skip/start behaviour --- changes.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/changes.go b/changes.go index e26a077..efe3036 100644 --- a/changes.go +++ b/changes.go @@ -364,8 +364,9 @@ type QueryOptions struct { type QueryChangeOptions struct { QueryOptions - // The S or start query parameter can be supplied to skip a number of changes from the list. - Skip int `url:"S,omitempty"` + // The S or start query parameter can be supplied to skip a number of changes from the list. Only one of the two parameters can be set at a time. + Skip int `url:"S,omitempty"` + Start int `url:"start,omitempty"` ChangeOptions } @@ -390,6 +391,10 @@ type ChangeOptions struct { func (s *ChangesService) QueryChanges(opt *QueryChangeOptions) (*[]ChangeInfo, *Response, error) { u := "changes/" + if (opt.Skip == opt.Start) || (opt.Skip == 0) || (opt.Start == 0) { + return nil, nil, errors.New("the query parameters `skip` (`S`) and `start` are conflicting") + } + u, err := addOptions(u, opt) if err != nil { return nil, nil, err From c23b0aa58ddc538c1e98b094e238ae716fdd8173 Mon Sep 17 00:00:00 2001 From: Michael Dorner Date: Sun, 10 May 2020 14:16:47 +0200 Subject: [PATCH 4/7] corrected S parameter according to Gerrit API documentation --- projects.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects.go b/projects.go index f2c0bd1..1541087 100644 --- a/projects.go +++ b/projects.go @@ -193,7 +193,7 @@ type ProjectOptions struct { Regex string `url:"r,omitempty"` // Skip the given number of projects from the beginning of the list. - Skip string `url:"S,omitempty"` + Start string `url:"start,omitempty"` // Limit the results to those projects that match the specified substring. Substring string `url:"m,omitempty"` From 0f323199d611c2f1b0b3227569f35aa2c6abcb2b Mon Sep 17 00:00:00 2001 From: Michael Dorner Date: Sun, 10 May 2020 14:22:18 +0200 Subject: [PATCH 5/7] fixed logic for Skip/Start check --- changes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes.go b/changes.go index efe3036..0e2a92b 100644 --- a/changes.go +++ b/changes.go @@ -391,7 +391,7 @@ type ChangeOptions struct { func (s *ChangesService) QueryChanges(opt *QueryChangeOptions) (*[]ChangeInfo, *Response, error) { u := "changes/" - if (opt.Skip == opt.Start) || (opt.Skip == 0) || (opt.Start == 0) { + if !(opt.Skip == opt.Start) || (opt.Skip == 0) || (opt.Start == 0) { return nil, nil, errors.New("the query parameters `skip` (`S`) and `start` are conflicting") } From 8871cec7969dd24bc53fb26a6e828c5e20ee0311 Mon Sep 17 00:00:00 2001 From: Michael Dorner Date: Mon, 11 May 2020 09:00:25 +0200 Subject: [PATCH 6/7] added parameter value output --- changes.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/changes.go b/changes.go index 0e2a92b..529cd50 100644 --- a/changes.go +++ b/changes.go @@ -391,8 +391,8 @@ type ChangeOptions struct { func (s *ChangesService) QueryChanges(opt *QueryChangeOptions) (*[]ChangeInfo, *Response, error) { u := "changes/" - if !(opt.Skip == opt.Start) || (opt.Skip == 0) || (opt.Start == 0) { - return nil, nil, errors.New("the query parameters `skip` (`S`) and `start` are conflicting") + if !(opt.Skip == opt.Start) || ((opt.Skip == 0) || (opt.Start == 0)) { + return nil, nil, fmt.Errorf("the query parameters `skip`/`S`(=%v)) and `start` (=%v) are conflicting", opt.Skip, opt.Start) } u, err := addOptions(u, opt) From dbb8e80a5aa0f7f66476aebf87211232f2c6af43 Mon Sep 17 00:00:00 2001 From: Michael Dorner Date: Mon, 11 May 2020 09:10:14 +0200 Subject: [PATCH 7/7] fixed small typo for the parameter value output (start and skip) --- changes.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/changes.go b/changes.go index 529cd50..301aafd 100644 --- a/changes.go +++ b/changes.go @@ -391,8 +391,8 @@ type ChangeOptions struct { func (s *ChangesService) QueryChanges(opt *QueryChangeOptions) (*[]ChangeInfo, *Response, error) { u := "changes/" - if !(opt.Skip == opt.Start) || ((opt.Skip == 0) || (opt.Start == 0)) { - return nil, nil, fmt.Errorf("the query parameters `skip`/`S`(=%v)) and `start` (=%v) are conflicting", opt.Skip, opt.Start) + if !(opt.Skip == opt.Start || opt.Skip == 0 || opt.Start == 0) { + return nil, nil, fmt.Errorf("the query parameters `skip`/`S`(=%v) and `start` (=%v) are conflicting", opt.Skip, opt.Start) } u, err := addOptions(u, opt)