From b38e4dfff2b4600d51504706953b5c6b9c5254ae Mon Sep 17 00:00:00 2001 From: William Desportes Date: Thu, 8 Oct 2020 22:27:07 +0200 Subject: [PATCH] Handle tag pushes Signed-off-by: William Desportes --- hooks/lib/github.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hooks/lib/github.php b/hooks/lib/github.php index adbf9d1..3987735 100644 --- a/hooks/lib/github.php +++ b/hooks/lib/github.php @@ -68,10 +68,12 @@ function github_webhook_push(stdClass $inputData): stdClass $data->repoName = $inputData->repository->full_name; $data->compare = $inputData->compare; $data->emailBody = $msg; - $data->headCommitTitle = explode("\n", $inputData->commits[0]->message)[0]; - $data->headCommitShortHash = substr($inputData->commits[0]->id, 0, 6); - $data->authorName = $inputData->commits[0]->author->name; - $data->authorEmail = $inputData->commits[0]->author->email; + // Commits can be empty and head_commit filled in case of a tag + $firstCommit = $inputData->commits[0] ?? $inputData->head_commit; + $data->headCommitTitle = explode("\n", $firstCommit->message)[0]; + $data->headCommitShortHash = substr($firstCommit->id, 0, 6); + $data->authorName = $firstCommit->author->name; + $data->authorEmail = $firstCommit->author->email; return $data; }