Files
boost-tasks/list-pull-requests
2017-12-28 19:35:16 +00:00

38 lines
1.0 KiB
PHP

#!/usr/bin/env php
<?php
require_once(__DIR__.'/vendor/autoload.php');
use GetOptionKit\OptionCollection;
use BoostTasks\Settings;
use BoostTasks\CommandLineOptions;
function main($args) {
$specs = new OptionCollection;
$options = CommandLineOptions::process($args,
'List pull requests',
$specs);
if (is_numeric($options)) { exit($options); }
Settings::init($options);
$username = 'danieljames';
$organisation = 'boostorg';
$repos = array();
foreach(Settings::githubCache()->iterate("/users/{$username}/subscriptions") as $subscription) {
if ($subscription->owner->login == $organisation) {
$repos[] = $subscription->full_name;
}
}
if ($repos) {
$db = Settings::database();
$query = 'WHERE repo_full_name IN ( ?';
$query .= str_repeat(', ?', count($repos) - 1);
$query .= ' )';
$pull_requests = $db->findAll('pull_request', $query, $repos);
print_r($pull_requests);
}
}
main($_SERVER['argv']);