Add Pagination Options for List Requests #205
No reviewers
Labels
No Label
has/backport
has/pull
in progress
invalid
kind/breaking
kind/bug
kind/build
kind/deployment
kind/docs
kind/enhancement
kind/feature
kind/lint
kind/proposal
kind/question
kind/refactor
kind/security
kind/testing
kind/translation
kind/ui
need/backport
priority/critical
priority/low
priority/maybe
priority/medium
reviewed/duplicate
reviewed/invalid
reviewed/wontfix
skip-changelog
status/blocked
status/needs-feedback
status/needs-reviews
status/wip
upstream/gitea
No Milestone
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Reference: gitea/go-sdk#205
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "spawn2kill/go-sdk:pagination"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Same as #203
Please resolve the conflicts
@lunny only worth it after https://github.com/go-gitea/gitea/pull/9452 got merged ...
but it looks like nobody has time to review :/
@spawn2kill can you adjust this PR ? (now as your PR is merged upstream)
and fix conflict ;)
I will as soon as I get some free time :)
dont stress yourself ... since this will be a breaking change. And v0.11.0 is released first
By the way you should add a version check like this one:
7892df812a
And once again, an huge PR 😂
this need a litle b8t more work
why differ from
models/list_options.go
struct ?fixed
gitea/issue_milestone.go
-> #244ListrecourceOption
why remove the copyright header?
fixed
@ -0,0 +11,4 @@
PerPage int
}
func (o ListOptions) getURLQueryEncoded() string {
useles function you always can use
getURLQuery().Encode()
instead@ -0,0 +41,4 @@
}
}
func (o ListOptions) getPerPage() int {
i would ceep it simple and would remove
getPerPage()
instead use:
it makes it clear what the code does
@ -25,2 +25,4 @@
}
// ListOrgHooksOptions options for listing organization's hooks
type ListOrgHooksOptions struct {
why not use ListHooksOptions for ListOrgHooks() and ListRepoHooks() ?
fixed
@ -67,2 +116,4 @@
link.RawQuery = options.QueryEncode()
return issues, c.getParsedResponse("GET", link.String(), jsonHeader, nil, &issues)
}
dont delete
if len(opt.State) > 0 { ...
it was actually duplicated
o your right ... in this case it sure ok :)
I already have this fix in #243 :D
this could cause you or me a mergeconflict :)
@ -38,0 +47,4 @@
options.setDefaults()
comments := make([]*Comment, 0, options.PageSize)
if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil {
return comments, err
why make this function unusable for gitea instances below 1.12.0 ?!?
fixed
@ -0,0 +16,4 @@
}
func (o ListOptions) getURLQuery() url.Values {
o.setDefaults()
i would not implicit setDefaults as you have it explicit on each function anyway (give more indifidual control to each api call function)
fixed
@ -0,0 +30,4 @@
o.Page = 1
}
if o.PageSize < 0 || o.PageSize > 50 {
can you add a varialbe on the beginging of
gitea/list_options.go
witch contain this vaule (50)?fixed
@ -24,2 +24,4 @@
}
// ListMyOrgsOptions options for listing current user's organizations
type ListMyOrgsOptions struct {
can you let
ListMyOrgs()
andListUserOrgs()
useListOrgsOptions
?fixed
@ -23,2 +23,4 @@
}
// ListOrgTeamsOptions options for listing organization's teams
type ListOrgTeamsOptions struct {
same here -> ListTeamsOptions for ListOrgTeams() & ListMyTeams()
fixed
@ -58,3 +60,3 @@
// ListPullRequestsOptions options for listing pull requests
type ListPullRequestsOptions struct {
Page int `json:"page"`
ListOptions `json:"-"`
just use
ListOptions
fixed
@ -57,2 +57,4 @@
}
// ListMyReposOptions options for listing current's user repositories
type ListMyReposOptions struct {
ListReposOptions ... for ListMyRepos() ListUserRepos() ListOrgReposOptions()
fixed
@ -22,3 +39,1 @@
func (c *Client) ListMyFollowing(page int) ([]*User, error) {
users := make([]*User, 0, 10)
return users, c.getParsedResponse("GET", fmt.Sprintf("/user/following?page=%d", page), nil, nil, &users)
func (c *Client) ListMyFollowing(options ListMyFollowingOptions) ([]*User, error) {
use ListFollowingOptions for ListMyFollowing() too
fixed
@ -7,2 +7,4 @@
import "fmt"
// ListMyFollowersOptions options for listing current's user's followers
type ListMyFollowersOptions struct {
use ListFollowersOptions for ListMyFollowers() too
fixed
@ -40,4 +51,3 @@
}
// ListMyGPGKeys list all the GPG keys of current user
func (c *Client) ListMyGPGKeys() ([]*GPGKey, error) {
use ListMyGPGKeysOption for ListMyGPGKeys() too
fixed
@ -34,2 +34,4 @@
}
// ListGPGKeys options for listing a user's GPGKeys
type ListGPGKeys struct {
fixed
@ -34,3 +45,1 @@
func (c *Client) ListMyPublicKeys() ([]*PublicKey, error) {
keys := make([]*PublicKey, 0, 10)
return keys, c.getParsedResponse("GET", "/user/keys", nil, nil, &keys)
func (c *Client) ListMyPublicKeys(options ListMyPublicKeysOptions) ([]*PublicKey, error) {
use ListPublicKeysOptions for ListMyPublicKeys() too
fixed
need still some work
@ -21,2 +21,4 @@
}
// ListRepoLabelsOptions options for listing repository's labels
type ListRepoLabelsOptions struct {
ListLabelsOptions for ListRepoLabels() and GetIssueLabels()
@ -0,0 +22,4 @@
// ListRepoTopics list all repository's topics
func (c *Client) ListRepoTopics(user, repo string, opt ListRepoTopics) (*TopicsList, error) {
var list TopicsList
opt.setDefaults()
still some nits
🎉
@spawn2kill #254 is merged, so now you can also add pagination to it in this PR
pleace resolve conflict
gitea/issue_comment.go
gitea/user_app.go
@ -33,4 +44,2 @@
// ListRepoIssueComments list comments for a given repo.
func (c *Client) ListRepoIssueComments(owner, repo string) ([]*Comment, error) {
comments := make([]*Comment, 0, 10)
can you use ListIssueCommentsOptions for ListRepoIssueComments too?
found something
can you pleace resolve the conflichts ... yes they are back again :O
@ -26,0 +57,4 @@
test-instance:
rm -r ${WORK_DIR}/test 2> /dev/null; \
mkdir -p ${WORK_DIR}/test/conf/ ${WORK_DIR}/test/data/
wget "https://dl.gitea.io/gitea/master/gitea-master-darwin-10.6-amd64" -O ${WORK_DIR}/test/gitea-master; \
better use
git add -p
?@ -60,3 +66,1 @@
func (c *Client) ListMyRepos() ([]*Repository, error) {
repos := make([]*Repository, 0, 10)
return repos, c.getParsedResponse("GET", "/user/repos", nil, nil, &repos)
func (c *Client) ListMyRepos(opt *ListReposOptions) ([]*Repository, error) {
opt *ListReposOptions
->opt ListReposOptions
@ -62,2 +58,3 @@
jsonHeader, bytes.NewReader(body), status)
status := new(Status)
return status, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/statuses/%s", owner, repo, sha), jsonHeader, bytes.NewReader(body), status)
}
dont breake things if necesar!!
rename
ListStatusesOptions
back toListStatusesOption
@ -27,2 +27,4 @@
}
// ListAccessTokens options for listing a users's access tokens
type ListAccessTokens struct {
rename to ListAccessTokensOptions
lgtm
So this is major breaking change for the SDK almost every signature is changed.
added pagination options for listing requeststo Add Pagination Options for List Requests