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

Feature - Pagination for git tree API #5838

Merged
merged 27 commits into from Feb 6, 2019

Conversation

@richmahn
Copy link
Contributor

richmahn commented Jan 25, 2019

Issue #5837

This PR adds pagination to the repos/{owner}/{repo}/git/trees/{sha} API to not have the restriction Github has truncating to the first 1000 entries and not show any more (GitHub docs say to see all files of big repos you'll have to clone the repo, yet we are trying to avoid that in our mobile app).

Now if you add ?page=2 (page is 1 when not given) as a query parameter it will show the next page. If there are still more items after the specified page, truncated will remain as true, when it is the last page, truncated will be false.

Also adds per_page= where per_page is how many items to show per page. Default is 1000 and is settable in the app.ini file as DFAULT_GIT_TREES_PER_PAGE

This PR also adds to the API docs the recursive=1 and this page=# query parameters for this API call.

Testing:
Can be tested with a repo with lots of files, such as https://git.door43.org/unfoldingWord/en_ugl/ and then once ported into a repo fo the same name of your localhost root user, curl --request GET --url "http://localhost:3000/api/v1/repos/root/en_ugl/git/trees/master?recursive=1&page=2" for the 2nd page (curl --request GET --url "http://localhost:3000/api/v1/repos/root/en_ugl/git/trees/master?recursive=1&page=30" for the last page, and if you do page 31 you should get a tree that is null)

@techknowlogick

This comment has been minimized.

Copy link
Member

techknowlogick commented Jan 25, 2019

Please run make fmt and commit changes.

@techknowlogick

This comment has been minimized.

Copy link
Member

techknowlogick commented Jan 25, 2019

Please add per_page param as well, see #5831 for an example

@techknowlogick techknowlogick added this to the 1.8.0 milestone Jan 25, 2019

@richmahn

This comment has been minimized.

Copy link
Contributor Author

richmahn commented Jan 25, 2019

@techknowlogick Both your requests done. While I know Chinese, I didn't update the Chinese version of the cheat-sheet like the example you gave me. Hopefully picked an ok name for this additional paging num setting but made it different to not be confused with the one from your example.

@lunny

This comment has been minimized.

Copy link
Member

lunny commented Jan 25, 2019

@richmahn I think we should start page from 1 not 0 since every other place did that.

@lunny

This comment has been minimized.

Copy link
Member

lunny commented Jan 25, 2019

And the CI failed.

Show resolved Hide resolved routers/api/v1/repo/tree.go Outdated
@lafriks

This comment has been minimized.

Copy link
Member

lafriks commented Jan 25, 2019

To fix CI run:

make generate-swagger
@richmahn

This comment has been minimized.

Copy link
Contributor Author

richmahn commented Jan 25, 2019

@lunny ok, fixed and fixed.

@codecov-io

This comment has been minimized.

Copy link

codecov-io commented Jan 25, 2019

Codecov Report

Merging #5838 into master will increase coverage by 0.08%.
The diff coverage is 45.83%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5838      +/-   ##
==========================================
+ Coverage   38.71%   38.79%   +0.08%     
==========================================
  Files         330      330              
  Lines       48697    48729      +32     
==========================================
+ Hits        18853    18906      +53     
+ Misses      27115    27083      -32     
- Partials     2729     2740      +11
Impacted Files Coverage Δ
modules/setting/setting.go 51.77% <ø> (ø) ⬆️
routers/api/v1/repo/tree.go 41.12% <45.83%> (+41.12%) ⬆️
models/unit.go 14.28% <0%> (+14.28%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0c840a9...64b3858. Read the comment docs.

techknowlogick and others added some commits Jan 28, 2019

Merge branch 'feature/pagination-for-git-tree-api' of github.com:rich…
…mahn/gitea into feature/pagination-for-git-tree-api
Show resolved Hide resolved routers/api/v1/repo/tree.go Outdated
@techknowlogick

This comment has been minimized.

Copy link
Member

techknowlogick commented Feb 3, 2019

@richmahn to update vendor Gopkg.toml (and related files) the command to run is dep ensure -update code.gitea.io/sdk

richmahn added some commits Feb 5, 2019

Show resolved Hide resolved templates/swagger/v1_json.tmpl Outdated

richmahn added some commits Feb 5, 2019

@sapk

sapk approved these changes Feb 6, 2019

@GiteaBot GiteaBot added lgtm/done and removed lgtm/need 1 labels Feb 6, 2019

@lafriks

This comment has been minimized.

Copy link
Member

lafriks commented Feb 6, 2019

@zeripath need your review

@zeripath zeripath merged commit da1edbf into go-gitea:master Feb 6, 2019

2 checks passed

approvals/lgtm this commit looks good
continuous-integration/drone/pr the build was successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment