Commit: 8d529985963af580d218d416de1abe763be89d2d Author: Nikita Popov <ni...@php.net> Tue, 15 Nov 2016 21:51:53 +0100 Parents: 2320705c2bcedccf694c8e88eb3e6c1a7bb247f6 Branches: master
Link: http://git.php.net/?p=web/master.git;a=commitdiff;h=8d529985963af580d218d416de1abe763be89d2d Log: Handle pull request comments as well These are distinct from review comments. I've cannibalized the base-branch in the mail subject to support this easily. This does not seem like particularly important information in most cases. Changed paths: M github-webhook.php Diff: diff --git a/github-webhook.php b/github-webhook.php index 7578916..f756e81 100644 --- a/github-webhook.php +++ b/github-webhook.php @@ -21,14 +21,11 @@ function get_repo_email($repos, $repoName) { return $to; } -function prep_title($PR, $base) { +function prep_title($PR, $repoName) { $PRNumber = $PR->number; $title = $PR->title; - $repoName = $base->repo->name; - $targetBranch = $base->ref; - - $subject = sprintf('[PR][%s][#%s][%s] - %s', $repoName, $PRNumber, $targetBranch, $title); + $subject = sprintf('[PR][%s][#%s] - %s', $repoName, $PRNumber, $title); return $subject; } @@ -52,19 +49,21 @@ if (!verify_signature($body)) { $payload = json_decode($body); $action = $payload->action; -$PR = $payload->pull_request; -$htmlUrl = $PR->html_url; -$repoName = $PR->base->repo->name; +$repoName = $payload->repository->name; -switch ($_SERVER['HTTP_X_GITHUB_EVENT']) { +$event = $_SERVER['HTTP_X_GITHUB_EVENT']; +switch ($event) { case 'ping': break; case 'pull_request': + $PR = $payload->pull_request; + $htmlUrl = $PR->html_url; + $description = $PR->body; $username = $PR->user->login; $to = get_repo_email($CONFIG["repos"], $repoName); - $subject = prep_title($PR, $PR->base); + $subject = prep_title($PR, $repoName); $message = sprintf("You can view the Pull Request on github:\r\n%s", $htmlUrl); switch ($action) { @@ -94,11 +93,15 @@ switch ($_SERVER['HTTP_X_GITHUB_EVENT']) { break; case 'pull_request_review_comment': + case 'issue_comment': + $PR = $event == 'issue_comment' ? $payload->issue : $payload->pull_request; + $htmlUrl = $PR->html_url; + $username = $payload->comment->user->login; $comment = $payload->comment->body; $to = get_repo_email($CONFIG["repos"], $repoName); - $subject = prep_title($PR, $PR->base); + $subject = prep_title($PR, $repoName); $message = sprintf("You can view the Pull Request on github:\r\n%s", $htmlUrl); switch ($action) { case 'created': -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php