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
func populatePageValues can't handle API's returning 'since' #2112
Comments
I see that orgs Additionally, the only pagination documentation I could find is here: Can you please show an example header response that includes the |
Here is a slightly formatted and sanitised copy of our header - we are using GHE not github.com The func is parsing the Link entry |
OK, thank you, @brianlangdon ! Would you like to create a PR or would you like me to open up this issue for one of our other amazing contributors to address this issue? |
Hi @gmlewis, I'll give it a go, although I'm not sure how I'd create tests for it. |
OK, cool. It's yours, @brianlangdon . As for a test, check out this example, and create a new test based upon it (possibly even right after it): |
#2135 created |
As reported here: #2135 (comment) I tested this myself with the following test program: package main
import (
"context"
"log"
"time"
"github.com/google/go-github/v41/github"
)
func main() {
client := github.NewClient(nil)
ctx := context.Background()
since, err := time.Parse(time.RFC3339, "2021-12-04T10:43:42Z")
if err != nil {
log.Fatal(err)
}
opts := &github.CommitsListOptions{Since: since}
d, resp, err := client.Repositories.ListCommits(ctx, "Homebrew", "homebrew-cask", opts)
if err != nil {
log.Fatal(err)
}
log.Printf("len(d)=%v", len(d))
log.Printf("resp.Header=%#v", resp.Header)
log.Printf("resp.NextPage=%v", resp.NextPage)
log.Printf("resp.PrevPage=%v", resp.PrevPage)
log.Printf("resp.FirstPage=%v", resp.FirstPage)
log.Printf("resp.LastPage=%v", resp.LastPage)
log.Printf("resp.NextPageToken=%v", resp.NextPageToken)
log.Printf("resp.Cursor=%v", resp.Cursor)
log.Printf("resp.Before=%v", resp.Before)
log.Printf("resp.After=%v", resp.After)
} which returned:
This should say: |
API's such as the Organization ListAll can return many pages of Organizations. The pagination value is called since and holds the id of the last Org returned. A simple change to populatePageValues appears, so far, to be able to support this. Not sure if this a fault or a improvement! I'm new to golang so please forgive.
Old code in populatePageValues:
proposed change to populatePageValues
The text was updated successfully, but these errors were encountered: