From e3a5376d01e5946fb769d8ba4def3232d7f0116f Mon Sep 17 00:00:00 2001 From: Diep Pham Date: Thu, 25 Jan 2018 15:05:17 +0700 Subject: [PATCH] uses email from Sender field of push event Gitea/Gogs [set repository owner](https://github.com/go-gitea/gitea/blob/d644e8810710bc2e5035aa25f63c597c47312404/models/pull.go#L469) information as Pusher in webhook. For example, if we have a repository: git.example.com/org1/repo1, owner of repository will be `org1` and the email field will be empty. This PR changes gitea/gogs helpers to use the email in Sender field, which is the user that click the merge button. --- remote/gitea/fixtures/hooks.go | 1 + remote/gitea/helper.go | 2 +- remote/gitea/types.go | 1 + remote/gogs/fixtures/hooks.go | 1 + remote/gogs/helper.go | 2 +- remote/gogs/types.go | 1 + 6 files changed, 6 insertions(+), 2 deletions(-) diff --git a/remote/gitea/fixtures/hooks.go b/remote/gitea/fixtures/hooks.go index 8f79ff3e2..8c0dda3f6 100644 --- a/remote/gitea/fixtures/hooks.go +++ b/remote/gitea/fixtures/hooks.go @@ -46,6 +46,7 @@ const HookPush = ` "login": "gordon", "id": 1, "username": "gordon", + "email": "gordon@golang.org", "avatar_url": "http://gitea.golang.org///1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87" } } diff --git a/remote/gitea/helper.go b/remote/gitea/helper.go index 587daf383..183324a70 100644 --- a/remote/gitea/helper.go +++ b/remote/gitea/helper.go @@ -77,7 +77,7 @@ func buildFromPush(hook *pushHook) *model.Build { Message: hook.Commits[0].Message, Avatar: avatar, Author: author, - Email: hook.Pusher.Email, + Email: hook.Sender.Email, Timestamp: time.Now().UTC().Unix(), Sender: sender, } diff --git a/remote/gitea/types.go b/remote/gitea/types.go index 1671bd812..2f1ebcd60 100644 --- a/remote/gitea/types.go +++ b/remote/gitea/types.go @@ -38,6 +38,7 @@ type pushHook struct { ID int64 `json:"id"` Login string `json:"login"` Username string `json:"username"` + Email string `json:"email"` Avatar string `json:"avatar_url"` } `json:"sender"` } diff --git a/remote/gogs/fixtures/hooks.go b/remote/gogs/fixtures/hooks.go index e9c19dba5..fdd1fda15 100644 --- a/remote/gogs/fixtures/hooks.go +++ b/remote/gogs/fixtures/hooks.go @@ -44,6 +44,7 @@ var HookPush = ` "sender": { "login": "gordon", "id": 1, + "email": "gordon@golang.org", "avatar_url": "http://gogs.golang.org///1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87" } } diff --git a/remote/gogs/helper.go b/remote/gogs/helper.go index 8b9420ed7..9bd965591 100644 --- a/remote/gogs/helper.go +++ b/remote/gogs/helper.go @@ -77,7 +77,7 @@ func buildFromPush(hook *pushHook) *model.Build { Message: hook.Commits[0].Message, Avatar: avatar, Author: author, - Email: hook.Pusher.Email, + Email: hook.Sender.Email, Timestamp: time.Now().UTC().Unix(), Sender: sender, } diff --git a/remote/gogs/types.go b/remote/gogs/types.go index 611004455..c4bed21a6 100644 --- a/remote/gogs/types.go +++ b/remote/gogs/types.go @@ -37,6 +37,7 @@ type pushHook struct { ID int64 `json:"id"` Login string `json:"login"` Username string `json:"username"` + Email string `json:"email"` Avatar string `json:"avatar_url"` } `json:"sender"` }