From 63fba676b13c0d59da6731fd4aec882a7f449135 Mon Sep 17 00:00:00 2001 From: Mura Li Date: Mon, 11 Jun 2018 16:47:25 +0800 Subject: [PATCH] Fix out-of-bounds error when a push doesn't contain commits --- remote/gitea/helper.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/remote/gitea/helper.go b/remote/gitea/helper.go index 0b0a918ac..e330545f6 100644 --- a/remote/gitea/helper.go +++ b/remote/gitea/helper.go @@ -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,