Merge pull request #2434 from typeless/push-500

Fix out-of-bounds error when a push doesn't contain commits
This commit is contained in:
Brad Rydzewski 2018-10-17 09:55:38 -07:00 committed by GitHub
commit 4165f8def1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -82,13 +82,18 @@ func buildFromPush(hook *pushHook) *model.Build {
sender = hook.Sender.Login
}
message := ""
if len(hook.Commits) > 0 {
message = hook.Commits[0].Message
}
return &model.Build{
Event: model.EventPush,
Commit: hook.After,
Ref: hook.Ref,
Link: hook.Compare,
Branch: strings.TrimPrefix(hook.Ref, "refs/heads/"),
Message: hook.Commits[0].Message,
Message: message,
Avatar: avatar,
Author: author,
Email: hook.Sender.Email,