Skip to content

Commit d4f010d

Browse files
author
Hubot
committed
Sync changes from upstream repository
1 parent abfffd7 commit d4f010d

3 files changed

Lines changed: 23 additions & 8 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
kind: change
3+
title: Improved pagination for the Repository Commits API
4+
created_at: 2014-05-09
5+
author_name: izuzak
6+
---
7+
8+
The [Repository Commits API](/v3/repos/commits/) now supports an additional approach for paginating [commit lists](/v3/repos/commits/#list-commits-on-a-repository). As of today, this endpoint supports the "standard" [`page` and `per_page` parameters](/v3/#pagination) for controlling pagination. This API now uses these parameters by default when constructing [page links](/v3/#pagination).
9+
10+
# Improved results and increased consistency
11+
12+
This new approach improves the reliability of this endpoint, which on rare occasions skipped some commits during pagination. This enhancement also increases the overall consistency of the API, as all endpoints now paginate resource lists the same way.
13+
14+
# Old parameters still supported
15+
16+
The old way of paginating, using `top`, `last_sha`, and `per_page` parameters, is still supported in API v3, but it will be removed in the [next major version of the API](https://developer.github.com/v3/versions/#v3-deprecations). API clients that are manually constructing URLs for pages should be modified to use the new parameters. Even better, API clients shouldn't construct URLs for pages manually, but should use [page links provided by the `Link` header](/guides/traversing-with-pagination/) in API responses.
17+
18+
Since both the new and the old pagination parameters are still supported in API v3, API clients shouldn't notice any changes today. Still, if you notice any problems with this endpoint, please [let us know](https://github.com/contact?form%5Bsubject%5D=API:+Commits+pagination+improvements).

content/v3/repos/commits.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ The Repo Commits API supports listing, viewing, and comparing commits in a repos
1313

1414
GET /repos/:owner/:repo/commits
1515

16-
_A special note on pagination:_ Due to the way Git works, commits are paginated
17-
based on SHA instead of page number. Please follow the link headers as outlined
18-
in the [pagination overview](https://developer.github.com/v3/#pagination)
19-
instead of constructing page links yourself.
20-
2116
### Parameters
2217

2318
Name | Type | Description
@@ -32,9 +27,7 @@ Name | Type | Description
3227
### Response
3328

3429
<%=
35-
headers 200, :pagination => {
36-
:next => 'https://api.github.com/repositories/417862/commits?top=master&last_sha=4f9890864feb48296917c2fcf3682d8dc3adf16a'
37-
}
30+
headers 200, :pagination => default_pagination_rels
3831
%>
3932
<%= json(:commit) { |h| [h] } %>
4033

content/v3/versions.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ The recommendations below will help you prepare your application for the next ma
9191
1. User attribute: bio
9292
: Recommendation: Do not use this attribute. It is obsolete.
9393

94+
1. Pagination parameters `top` and `sha` for method: /repos/:owner/:repo/commits
95+
: Recommendation: When fetching [the list of commits for a repository](/v3/repos/commits/#list-commits-on-a-repository)
96+
use the [standard `per_page` and `page` parameters](/v3/#pagination) for pagination, instead of `per_page`,
97+
`top`, and `sha`.
9498

9599
# beta (Deprecated) {#beta}
96100

0 commit comments

Comments
 (0)