public function handlePush()
{
// We only care about push events
if ($this->request->header('X-Event-Key') !== 'repo:push') {
return false;
}
$payload = collect($this->request->json('push'));
// Invalid event from bitbucket
if (!$payload->has('changes') || !count($payload->get('changes', []))) {
return false;
}
$head = $payload->get('changes')[0]['new'];
list($name, $email) = explode(' <', trim($head['target']['author']['raw'], '> '));
return ['reason' => trim($head['target']['message']), 'branch' => $head['name'], 'source' => 'Bitbucket', 'build_url' => $head['target']['links']['html']['href'], 'commit' => $head['target']['hash'], 'committer' => $name, 'committer_email' => $email];
}