Author: Nikita Popov (nikic)
Date: 2021-12-05T16:09:56+01:00
Commit:
https://github.com/php/web-master/commit/be788e68aec645a51c158f553257a82e1cc9f9ef
Raw diff:
https://github.com/php/web-master/commit/be788e68aec645a51c158f553257a82e1cc9f9ef.diff
Specify separate issue mailing list for php-src
And do some formatting tweaks
Changed paths:
M public/github-webhook.php
Diff:
diff --git a/public/github-webhook.php b/public/github-webhook.php
index 2e217d9..85eb594 100644
--- a/public/github-webhook.php
+++ b/public/github-webhook.php
@@ -15,28 +15,16 @@ function verify_signature($requestBody) {
return false;
}
-function get_repo_email($repos, $repoName) {
- // if we somehow end up receiving a PR for a repo not matching anything
send it to systems so that we can fix it
- $to = '[email protected]';
- foreach ($repos as $repoPrefix => $email) {
- if (strpos($repoName, $repoPrefix) === 0) {
- $to = $email;
- }
- }
-
- return $to;
-}
-
function is_pr($issue) {
return strpos($issue->html_url, '/pull/') !== false;
}
-function prep_title($issue, $repoName) {
+function prep_title(object $issue, string $repoName): string {
$issueNumber = $issue->number;
$title = $issue->title;
$type = is_pr($issue) ? 'PR' : 'Issue';
- return sprintf('[%s][%s #%s] - %s', $repoName, $type, $issueNumber,
$title);
+ return sprintf('[%s] %s #%s: %s', $repoName, $type, $issueNumber, $title);
}
function send_mail($to, $subject, $message, MailAddress $from, array $replyTos
= []) {
@@ -135,6 +123,24 @@ function get_commit_mailing_list($repoName) {
}
}
+function get_issue_mailing_list(string $repoName, bool $isPR) {
+ if ($repoName === 'playground') {
+ return '[email protected]';
+ } else if ($repoName === 'php-src') {
+ if ($isPR) {
+ return '[email protected]';
+ } else {
+ return '[email protected]';
+ }
+ } else if (strpos($repoName, 'web-') === 0) {
+ return '[email protected]';
+ } else if (strpos($repoName, 'pecl-') === 0) {
+ return '[email protected]';
+ } else {
+ return null;
+ }
+}
+
function parse_ref($ref) {
if (!preg_match('(^refs/([^/]+)/(.+)$)', $ref, $matches)) {
return null;
@@ -303,16 +309,6 @@ function handle_push_mail($payload) {
}
}
-$CONFIG = [
- 'repos' => [
- 'php-langspec' => '[email protected]',
- 'php-src' => '[email protected]',
- 'web-' => '[email protected]',
- 'pecl-' => '[email protected]',
- 'playground' => '[email protected]',
- ],
-];
-
if (DRY_RUN) {
$body = file_get_contents("php://stdin");
$event = $argv[1];
@@ -347,11 +343,12 @@ function handle_push_mail($payload) {
$description = $issue->body;
$username = $issue->user->login;
- $to = get_repo_email($CONFIG["repos"], $repoName);
+ $isPR = is_pr($issue);
+ $to = get_issue_mailing_list($repoName, $isPR);
$subject = prep_title($issue, $repoName);
- $type = is_pr($issue) ? 'Pull Request' : 'Issue';
+ $type = $isPR ? 'Pull Request' : 'Issue';
- $message = sprintf("You can view the %s on github:\r\n%s", $type,
$htmlUrl);
+ $message = sprintf("%s: %s", $type, $htmlUrl);
switch ($action) {
case 'opened':
$message .= sprintf(
@@ -388,11 +385,12 @@ function handle_push_mail($payload) {
$username = $payload->comment->user->login;
$comment = $payload->comment->body;
- $to = get_repo_email($CONFIG["repos"], $repoName);
+ $isPR = is_pr($issue);
+ $to = get_issue_mailing_list($repoName, $isPR);
$subject = prep_title($issue, $repoName);
- $type = is_pr($issue) ? 'Pull Request' : 'Issue';
+ $type = $isPR ? 'Pull Request' : 'Issue';
- $message = sprintf("You can view the %s on github:\r\n%s", $type,
$htmlUrl);
+ $message = sprintf("%s: %s", $type, $htmlUrl);
switch ($action) {
case 'created':
$message .= sprintf("\r\n\r\nComment by %s:\r\n%s", $username,
$comment);
--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php