forked from danieljames/boost-tasks
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlist-pull-requests
37 lines (31 loc) · 1.01 KB
/
list-pull-requests
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/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']);