|
55 | 55 | ],
|
56 | 56 | ]);
|
57 | 57 |
|
| 58 | +// Fetch the user/org given as first argument to this script |
58 | 59 | unwrapObservableFromPromise($githubClient->user($argv[1])->then(function (UserInterface $user) use ($argv) {
|
59 | 60 | resource_pretty_print($user);
|
60 | 61 |
|
| 62 | + // Get all repositories for the given user |
61 | 63 | return $user->repositories();
|
62 | 64 | }))->filter(function (Repository $repository) {
|
| 65 | + // Filter out forks |
63 | 66 | return !$repository->fork();
|
64 | 67 | })->filter(function (Repository $repository) {
|
| 68 | + // Filter out repositories with nothing in them |
65 | 69 | return $repository->size() > 0;
|
66 | 70 | })->filter(function (Repository $repository) {
|
| 71 | + // Only check repositories that start with reactphp-http |
| 72 | + // This is optional and you can remove this to check all repositories |
| 73 | + // BUT that takes a lot of calls to check and time due to throttling |
67 | 74 | return strpos($repository->name(), 'reactphp-http') === 0;
|
68 | 75 | })->flatMap(function (Repository $repository) {
|
| 76 | + // Check if the repository contains a .travis.yml |
69 | 77 | return Observable::fromPromise(new React\Promise\Promise(function ($resolve, $reject) use ($repository) {
|
70 | 78 | $hasTravisYml = false;
|
71 | 79 | $repository->contents()->filter(function ($node) {
|
| 80 | + // Only let through files |
72 | 81 | return $node instanceof FileInterface;
|
73 | 82 | })->filter(function (File $file) {
|
| 83 | + // Only let the .travis.yml file through |
74 | 84 | return $file->name() === '.travis.yml';
|
75 | 85 | })->subscribe(function () use (&$hasTravisYml) {
|
76 | 86 | $hasTravisYml = true;
|
|
84 | 94 | })
|
85 | 95 | ->mapTo($repository);
|
86 | 96 | })->flatMap(function (Repository $repository) {
|
| 97 | + // Get Travis repository for the Github repository |
87 | 98 | return Observable::fromPromise($repository->travisRepository());
|
88 | 99 | })->flatMap(function (TravisRepository $repository) {
|
| 100 | + // Check if the repository on Travis is active |
| 101 | + // We're only interested in inactive repositories |
89 | 102 | return Observable::fromPromise($repository->isActive())
|
90 | 103 | ->filter(function ($isActive) {
|
91 | 104 | return !$isActive;
|
92 | 105 | })
|
93 | 106 | ->mapTo($repository);
|
94 | 107 | })->subscribe(function (TravisRepository $repository) {
|
| 108 | + // Activate repository on Travis |
95 | 109 | $repository->enable()->done(function (TravisRepository $repository) {
|
96 | 110 | resource_pretty_print($repository);
|
97 | 111 | }, 'display_throwable');
|
98 | 112 | }, 'display_throwable');
|
99 | 113 |
|
100 | 114 | $loop->run();
|
101 | 115 |
|
| 116 | +// Display Github API token status |
102 | 117 | displayState($githubClient->getRateLimitState());
|
0 commit comments