diff options
author | lstahlman <lstahlman@users.noreply.github.com> | 2016-08-09 22:01:57 -0700 |
---|---|---|
committer | 无闻 <u@gogs.io> | 2016-08-09 22:01:57 -0700 |
commit | 89f71b44f7e15c044ace56b4201b3e278947e91d (patch) | |
tree | 3b4d20b6176c755dd384f9b4c0101fc8301d76c1 /routers/api/v1/convert | |
parent | c5d4a9e046045f949ec9606b49dc37b928e83fb3 (diff) | |
download | gitea-89f71b44f7e15c044ace56b4201b3e278947e91d.tar.gz gitea-89f71b44f7e15c044ace56b4201b3e278947e91d.zip |
Add committer information to API and Webhooks. Also fixes #3271 (#3414)
Diffstat (limited to 'routers/api/v1/convert')
-rw-r--r-- | routers/api/v1/convert/convert.go | 22 |
1 files changed, 19 insertions, 3 deletions
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, } } |