Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Handle tag pushes
Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed Oct 8, 2020
1 parent 7bb8a6e commit b38e4df
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions hooks/lib/github.php
Expand Up @@ -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;
}
Expand Down

0 comments on commit b38e4df

Please sign in to comment.