Skip to content

Instantly share code, notes, and snippets.

@tierra
Last active October 26, 2015 01:25
Show Gist options
  • Save tierra/c65c39eb575741bf36fc to your computer and use it in GitHub Desktop.
Save tierra/c65c39eb575741bf36fc to your computer and use it in GitHub Desktop.
Utilities to support wxWidgets infrastructure.
{
"name": "tierra/wxUtilities",
"homepage": "http://www.wxwidgets.org/",
"description": "Utilities to support wxWidgets infrastructure.",
"keywords": ["wxwidgets", "github"],
"license": "MIT",
"authors": [
{
"name": "Bryan Petty",
"email": "bryan@ibaku.net"
}
],
"require": {
"knplabs/github-api": "~1.2.2"
}
}
{
"github": {
"user_agent": "wxWidgets Pull Request Maintainer (http://www.wxwidgets.org/)",
"token": "..."
},
"message": "Thank you for your contribution but we don't actually use Github\npull requests for this mirror of wxWidgets repository.\n\nPlease submit your changes to [our Trac](http://trac.wxwidgets.org) as explained [here](http://trac.wxwidgets.org/wiki/HowToSubmitTicket) instead.\n\nThanks in advance!",
"pull_requests": [
15,
12,
17,
16,
18,
19,
20,
21,
22
]
}
<?php
$settings_file = 'maintain-github-pulls.json';
require 'vendor/autoload.php';
$settings = json_decode(file_get_contents($settings_file), true);
$client = new Github\Client();
$client->getHttpClient()->setOption(
'user_agent', $settings['github']['user_agent']);
$client->authenticate($settings['github']['token'],
Github\Client::AUTH_HTTP_TOKEN);
echo "Fetching list of open issues...\n";
try {
$response = $client->getHttpClient()->get('search/issues',
array('q' => 'repo:wxWidgets/wxWidgets state:open'));
$issues = Github\HttpClient\Message\ResponseMediator::getContent($response);
} catch(Exception $exception) {
echo sprintf("Failed to fetch list of open issues: %s\n", $exception->getMessage());
exit(1);
}
foreach($issues['items'] as $pull) {
if(in_array($pull['number'], $settings['pull_requests'])) {
continue;
}
try {
$client->getHttpClient()->post($pull['comments_url'],
json_encode(array('body' => $settings['message']))
);
//$client->getHttpClient()->patch($pull['pull_request']['url'],
// json_encode(array('state' => 'closed'))
//);
} catch(Exception $exception) {
echo sprintf("Failed to comment on pull request <%s>: %s\n",
$pull['html_url'], $exception->getMessage());
continue;
}
echo sprintf("Commented on pull request: %s\n", $pull['html_url']);
$settings['pull_requests'][] = $pull['number'];
}
file_put_contents($settings_file, json_encode($settings));
exit("Finished maintaining pull requests.\n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment