-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Feature - Pagination for git tree API #5838
Conversation
Please run |
Please add |
@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. |
@richmahn I think we should start page from 1 not 0 since every other place did that. |
And the CI failed. |
To fix CI run:
|
@lunny ok, fixed and fixed. |
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
…mahn/gitea into feature/pagination-for-git-tree-api
…n-for-git-tree-api
@richmahn to update vendor Gopkg.toml (and related files) the command to run is |
…n-for-git-tree-api
@zeripath need your review |
* Feature - Pagination for git tree API * Handles case when page is negative * Does a for loop over the start and end rather than all entries * Removed redundent logic * Adds per_page as a query parameter * Adds DEFAULT_GIT_TREES_PER_PAGE for settings, ran make fmt * Fix typo in cheat-sheet en * Makes page start at 1, generated swagger * Use updates to SDK * Updates to use latest sdk * Updates swagger for tree api * Adds test for GetTreeBySHA * Updates per PR reviews * Updates per PR reviews * Remove file * Formatting * Fix to swagger file * Fix to swagger * Update v1_json.tmpl * Fix to swagger file
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 astrue
, when it is the last page, truncated will befalse
.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 thispage=#
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)