From 89f71b44f7e15c044ace56b4201b3e278947e91d Mon Sep 17 00:00:00 2001 From: lstahlman Date: Tue, 9 Aug 2016 22:01:57 -0700 Subject: Add committer information to API and Webhooks. Also fixes #3271 (#3414) --- routers/api/v1/convert/convert.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'routers/api/v1/convert') diff --git a/routers/api/v1/convert/convert.go b/routers/api/v1/convert/convert.go index 0dc73fcd67..cda1d86b45 100644 --- a/routers/api/v1/convert/convert.go +++ b/routers/api/v1/convert/convert.go @@ -69,15 +69,31 @@ func ToBranch(b *models.Branch, c *git.Commit) *api.Branch { } func ToCommit(c *git.Commit) *api.PayloadCommit { + authorUsername := "" + author, err := models.GetUserByEmail(c.Author.Email) + if err == nil { + authorUsername = author.Name + } + committerUsername := "" + committer, err := models.GetUserByEmail(c.Committer.Email) + if err == nil { + committerUsername = committer.Name + } return &api.PayloadCommit{ ID: c.ID.String(), Message: c.Message(), URL: "Not implemented", Author: &api.PayloadAuthor{ - Name: c.Committer.Name, - Email: c.Committer.Email, - /* UserName: c.Committer.UserName, */ + Name: c.Author.Name, + Email: c.Author.Email, + UserName: authorUsername, + }, + Committer: &api.PayloadCommitter{ + Name: c.Committer.Name, + Email: c.Committer.Email, + UserName: committerUsername, }, + Timestamp: c.Author.When, } } -- cgit v1.2.3