mirror of
https://github.com/samsonjs/retrogit.git
synced 2026-04-27 15:07:43 +00:00
Handle 409 responses when trying to list commits.
This commit is contained in:
parent
0cc4188964
commit
7852b128df
1 changed files with 5 additions and 2 deletions
|
|
@ -48,7 +48,7 @@ func computeVintage(c appengine.Context, userId int, userLogin string, repoOwner
|
||||||
// Cheap check to see if there are commits before the creation time.
|
// Cheap check to see if there are commits before the creation time.
|
||||||
vintage := repo.CreatedAt.UTC()
|
vintage := repo.CreatedAt.UTC()
|
||||||
beforeCreationTime := repo.CreatedAt.UTC().AddDate(0, 0, -1)
|
beforeCreationTime := repo.CreatedAt.UTC().AddDate(0, 0, -1)
|
||||||
commits, _, err := githubClient.Repositories.ListCommits(
|
commits, response, err := githubClient.Repositories.ListCommits(
|
||||||
repoOwnerLogin,
|
repoOwnerLogin,
|
||||||
repoName,
|
repoName,
|
||||||
&github.CommitsListOptions{
|
&github.CommitsListOptions{
|
||||||
|
|
@ -56,7 +56,10 @@ func computeVintage(c appengine.Context, userId int, userLogin string, repoOwner
|
||||||
Author: userLogin,
|
Author: userLogin,
|
||||||
Until: beforeCreationTime,
|
Until: beforeCreationTime,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if response.StatusCode == 409 {
|
||||||
|
// GitHub returns with a 409 when a repository is empty.
|
||||||
|
commits = make([]github.RepositoryCommit, 0)
|
||||||
|
} else if err != nil {
|
||||||
c.Errorf("Could not load commits for repo %s: %s", *repo.FullName, err.Error())
|
c.Errorf("Could not load commits for repo %s: %s", *repo.FullName, err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue