dmitri.shuralyov.com/service/change/githubapi

Fall back to git user when github user is missing.
dmitshur committed 6 years ago commit 0493202ef5f73b299291d6aa0ad2f5338c197e46
Showing partial commit. Full Commit
Collapse all
githubapi/githubapi.go
@@ -219,11 +219,11 @@ func (s service) ListCommits(ctx context.Context, rs string, id uint64) ([]chang
	var commits []change.Commit
	for _, c := range cs {
		commits = append(commits, change.Commit{
			SHA:        *c.SHA,
			Message:    *c.Commit.Message,
			Author:     ghV3User(c.Author),
			Author:     ghV3UserOrGitUser(c.Author, c.Commit.Author),
			AuthorTime: *c.Commit.Author.Date,
		})
	}
	return commits, nil
}
@@ -612,10 +612,21 @@ func ghUser(user githubqlUser) users.User {
		AvatarURL: user.AvatarURL,
		HTMLURL:   user.URL,
	}
}

func ghV3UserOrGitUser(user *github.User, gitUser *github.CommitAuthor) users.User {
	if user == nil {
		return users.User{
			Name:      *gitUser.Name,
			Email:     *gitUser.Email,
			AvatarURL: "https://secure.gravatar.com/avatar?d=mm&f=y&s=96", // TODO: Use email.
		}
	}
	return ghV3User(user)
}

func ghV3User(user *github.User) users.User {
	if *user.ID == 0 {
		return ghost // Deleted user, replace with https://github.com/ghost.
	}
	return users.User{