Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding pagination of repositories on bitbucketserver #1777

Merged
merged 2 commits into from
Sep 1, 2016

Conversation

thiago
Copy link

@thiago thiago commented Aug 30, 2016

Fix issue #1776

@CLAassistant
Copy link

CLAassistant commented Aug 30, 2016

CLA assistant check
All committers have signed the CLA.

if err != nil {
return nil, err
}
log.Debug(fmt.Printf("repoResponse: %+v\n", repoResponse))
Copy link

@bradrydzewski bradrydzewski Aug 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while in the code, some minor things that could be improved:

-log.Debug(fmt.Printf("repoResponse: %+v\n", repoResponse))
+log.Debugf("repoResponse: %+v", repoResponse)

@josmo
Copy link

josmo commented Aug 30, 2016

LGTM :) Thanks @thiago

@appleboy
Copy link

LGTM! 👍

@josmo
Copy link

josmo commented Aug 31, 2016

Btw not sure on you're end but making the limit 400 instead of 1000 may make it a little more responsive. I haven't tried it but might be worth checking out

@thiago
Copy link
Author

thiago commented Aug 31, 2016

it does not make it slower?

@bradrydzewski
Copy link

bradrydzewski commented Sep 1, 2016

Btw not sure on you're end but making the limit 400 instead of 1000 may make it a little more responsive. I haven't tried it but might be worth checking out

I'll merge and this can be handled in a follow-up pull request. The current implementation could probably be improved a bit more to more closely mirror the existing bitbucket implementation, but this can be done separately:

func (c *Client) ListRepos(account string, opts *ListOpts) (*RepoResp, error) {
    out := new(RepoResp)
    uri := fmt.Sprintf(pathRepos, c.base, account, opts.Encode())
    err := c.do(uri, get, nil, out)
    return out, err
}

func (c *Client) ListReposAll(account string) ([]*Repo, error) {
    var page = 1
    var repos []*Repo

    for {
        resp, err := c.ListRepos(account, &ListOpts{Page: page, PageLen: 100})
        if err != nil {
            return repos, err
        }
        repos = append(repos, resp.Values...)
        if len(resp.Next) == 0 {
            break
        }
        page = resp.Page + 1
    }
    return repos, nil
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants