From 7852b128dfb8ada29e5583d3b13153406479f080 Mon Sep 17 00:00:00 2001 From: Mihai Parparita Date: Sat, 30 Aug 2014 23:20:19 -0700 Subject: [PATCH] Handle 409 responses when trying to list commits. --- app/repos.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/repos.go b/app/repos.go index 9c5b968..f95e167 100644 --- a/app/repos.go +++ b/app/repos.go @@ -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. vintage := repo.CreatedAt.UTC() beforeCreationTime := repo.CreatedAt.UTC().AddDate(0, 0, -1) - commits, _, err := githubClient.Repositories.ListCommits( + commits, response, err := githubClient.Repositories.ListCommits( repoOwnerLogin, repoName, &github.CommitsListOptions{ @@ -56,7 +56,10 @@ func computeVintage(c appengine.Context, userId int, userLogin string, repoOwner Author: userLogin, 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()) return err }