public function handlePush()
{
// We only care about push events
if ($this->request->header('X-Gogs-Event') !== 'push') {
return false;
}
$payload = $this->request->json();
$commits = $payload->get('commits');
if (!is_array($commits) || count($commits) == 0) {
return false;
}
$head = array_shift($commits);
$branch = preg_replace('#refs/(tags|heads)/#', '', $payload->get('ref'));
return ['reason' => trim($head['message']), 'branch' => $branch, 'source' => 'Gogs', 'build_url' => $head['url'], 'commit' => $head['id'], 'committer' => $head['committer']['name'], 'committer_email' => $head['committer']['email']];
}