Avoid panic in github input (#6152)

This commit is contained in:
Greg 2019-07-22 17:30:53 -06:00 committed by Daniel Nelson
parent 3e50db904a
commit afe86c0f46
1 changed files with 10 additions and 10 deletions

View File

@ -148,9 +148,9 @@ func splitRepositoryName(repositoryName string) (string, string, error) {
return splits[0], splits[1], nil return splits[0], splits[1], nil
} }
func getLicense(repositoryInfo *github.Repository) string { func getLicense(rI *github.Repository) string {
if repositoryInfo.GetLicense() != nil { if licenseName := rI.GetLicense().GetName(); licenseName != "" {
return *repositoryInfo.License.Name return licenseName
} }
return "None" return "None"
@ -158,19 +158,19 @@ func getLicense(repositoryInfo *github.Repository) string {
func getTags(repositoryInfo *github.Repository) map[string]string { func getTags(repositoryInfo *github.Repository) map[string]string {
return map[string]string{ return map[string]string{
"owner": *repositoryInfo.Owner.Login, "owner": repositoryInfo.GetOwner().GetLogin(),
"name": *repositoryInfo.Name, "name": repositoryInfo.GetName(),
"language": *repositoryInfo.Language, "language": repositoryInfo.GetLanguage(),
"license": getLicense(repositoryInfo), "license": getLicense(repositoryInfo),
} }
} }
func getFields(repositoryInfo *github.Repository) map[string]interface{} { func getFields(repositoryInfo *github.Repository) map[string]interface{} {
return map[string]interface{}{ return map[string]interface{}{
"stars": *repositoryInfo.StargazersCount, "stars": repositoryInfo.GetStargazersCount(),
"forks": *repositoryInfo.ForksCount, "forks": repositoryInfo.GetForksCount(),
"open_issues": *repositoryInfo.OpenIssuesCount, "open_issues": repositoryInfo.GetOpenIssuesCount(),
"size": *repositoryInfo.Size, "size": repositoryInfo.GetSize(),
} }
} }