mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-23 00:46:30 +00:00
Fix out-of-bounds error when a push doesn't contain commits
This commit is contained in:
parent
29785b86f6
commit
63fba676b1
1 changed files with 6 additions and 1 deletions
|
@ -82,13 +82,18 @@ func buildFromPush(hook *pushHook) *model.Build {
|
||||||
sender = hook.Sender.Login
|
sender = hook.Sender.Login
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message := ""
|
||||||
|
if len(hook.Commits) > 0 {
|
||||||
|
message = hook.Commits[0].Message
|
||||||
|
}
|
||||||
|
|
||||||
return &model.Build{
|
return &model.Build{
|
||||||
Event: model.EventPush,
|
Event: model.EventPush,
|
||||||
Commit: hook.After,
|
Commit: hook.After,
|
||||||
Ref: hook.Ref,
|
Ref: hook.Ref,
|
||||||
Link: hook.Compare,
|
Link: hook.Compare,
|
||||||
Branch: strings.TrimPrefix(hook.Ref, "refs/heads/"),
|
Branch: strings.TrimPrefix(hook.Ref, "refs/heads/"),
|
||||||
Message: hook.Commits[0].Message,
|
Message: message,
|
||||||
Avatar: avatar,
|
Avatar: avatar,
|
||||||
Author: author,
|
Author: author,
|
||||||
Email: hook.Sender.Email,
|
Email: hook.Sender.Email,
|
||||||
|
|
Loading…
Reference in a new issue