uses email from Sender field of push event

Gitea/Gogs [set repository owner](d644e88107/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.
This commit is contained in:
Diep Pham 2018-01-25 15:05:17 +07:00
parent 5722ce410a
commit e3a5376d01
6 changed files with 6 additions and 2 deletions

View file

@ -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"
}
}

View file

@ -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,
}

View file

@ -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"`
}

View file

@ -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"
}
}

View file

@ -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,
}

View file

@ -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"`
}