diff --git a/core/section/github/commits.go b/core/section/github/commits.go index f425fb67..9b756961 100644 --- a/core/section/github/commits.go +++ b/core/section/github/commits.go @@ -171,26 +171,7 @@ func getCommits(client *gogithub.Client, config *githubConfig) ([]githubCommit, if v.Author != nil { if v.Author.Login != nil { al = *v.Author.Login - an = al - - if content, found := config.UserNames[al]; found { - if len(content) > 0 { - an = content - } - } else { - usr, _, err := client.Users.Get(al) - if err == nil { - if usr.Name != nil { - if len(*usr.Name) > 0 { - config.UserNames[al] = *usr.Name - an = *usr.Name - } - } - } else { - config.UserNames[al] = al // don't look again for a missing name - } - } - + an = getUserName(client, config, al) } if v.Author.AvatarURL != nil { @@ -315,6 +296,8 @@ func renderCommits(payload *githubRender, c *githubConfig) error { payload.HasAuthorStats = len(payload.AuthorStats) > 0 sort.Sort(asToSort(payload.AuthorStats)) + payload.NumContributors = len(payload.AuthorStats) - 1 + return nil } diff --git a/core/section/github/issues.go b/core/section/github/issues.go index 9afcdb8a..cbbb9121 100644 --- a/core/section/github/issues.go +++ b/core/section/github/issues.go @@ -28,6 +28,7 @@ type githubIssue struct { Message string `json:"message"` URL template.URL `json:"url"` Name string `json:"name"` + Creator string `json:"creator"` Avatar string `json:"avatar"` Labels template.HTML `json:"labels"` LabelNames []string `json:"labelNames"` @@ -152,6 +153,7 @@ func getIssues(client *gogithub.Client, config *githubConfig) ([]githubIssue, er l, ln, lc := wrapLabels(v.Labels) ret = append(ret, githubIssue{ Name: n, + Creator: getUserName(client, config, *v.User.Login), Avatar: av, Message: *v.Title, Date: v.CreatedAt.Format(issuesTimeFormat), diff --git a/core/section/github/issues_template.go b/core/section/github/issues_template.go index 29550981..2cf5f40e 100644 --- a/core/section/github/issues_template.go +++ b/core/section/github/issues_template.go @@ -73,7 +73,7 @@ const (
{{$data.Repo}}

- opened on {{$data.Date}} by {{$data.Name}} + {{$data.Creator}} opened on {{$data.Date}} {{end}} diff --git a/core/section/github/model.go b/core/section/github/model.go index 56133b9e..0c826314 100644 --- a/core/section/github/model.go +++ b/core/section/github/model.go @@ -45,6 +45,7 @@ type githubRender struct { ClosedPRs int `json:"closedPRs"` AuthorStats []githubAuthorStats `json:"authorStats"` HasAuthorStats bool `json:"hasAuthorStats"` + NumContributors int `json:"numContributors"` } type report struct { @@ -139,6 +140,11 @@ func (c *githubConfig) Clean() { if lastItem < len(c.Lists) { c.Lists[lastItem].Comma = false } + + if c.UserNames == nil { + c.UserNames = make(map[string]string) + } + } type githubCallbackT struct { @@ -156,3 +162,25 @@ func repoName(branchName string) string { } return pieces[0] } + +func getUserName(client *gogithub.Client, config *githubConfig, login string) (fullName string) { + an := login + if content, found := config.UserNames[login]; found { + if len(content) > 0 { + an = content + } + } else { + usr, _, err := client.Users.Get(login) + if err == nil { + if usr.Name != nil { + if len(*usr.Name) > 0 { + config.UserNames[login] = *usr.Name + an = *usr.Name + } + } + } else { + config.UserNames[login] = login // don't look again for a missing name + } + } + return an +}