|
5 | 5 |
|
6 | 6 | require_once __DIR__ . '/vendor/autoload.php'; |
7 | 7 |
|
| 8 | +use Github\Api\Repo; |
8 | 9 | use Github\Api\Search; |
9 | 10 | use Github\AuthMethod; |
10 | 11 | use Github\Client; |
@@ -54,6 +55,9 @@ protected function execute(InputInterface $input, OutputInterface $output) |
54 | 55 | /** @var Search $searchApi */ |
55 | 56 | $searchApi = $gitHubClient->api('search'); |
56 | 57 |
|
| 58 | + /** @var Repo $repoApi */ |
| 59 | + $repoApi = $gitHubClient->api('repo'); |
| 60 | + |
57 | 61 | $command = ['git', 'log', sprintf('%s..%s', $input->getArgument('fromCommit'), $input->getArgument('toCommit'))]; |
58 | 62 | $excludeBranch = $input->getOption('exclude-branch'); |
59 | 63 | if ($excludeBranch !== null) { |
@@ -110,9 +114,15 @@ protected function execute(InputInterface $input, OutputInterface $output) |
110 | 114 | } |
111 | 115 |
|
112 | 116 | foreach ($commits as $commit) { |
113 | | - $pullRequests = $searchApi->issues(sprintf('repo:phpstan/phpstan-src %s is:pull-request', $commit['hash'])); |
114 | | - $issues = $searchApi->issues(sprintf('repo:phpstan/phpstan %s is:issue', $commit['hash']), 'created'); |
115 | | - $items = array_merge($pullRequests['items'], $issues['items']); |
| 117 | + $pullRequests = $repoApi->commits()->pulls('phpstan', 'phpstan-src', $commit['hash']); |
| 118 | + $items = $searchApi->issues(sprintf('repo:phpstan/phpstan %s is:issue', $commit['hash']), 'created')['items']; |
| 119 | + if (count($pullRequests) > 0) { |
| 120 | + $items[] = [ |
| 121 | + 'pull_request' => true, |
| 122 | + 'number' => $pullRequests[0]['number'], |
| 123 | + 'user' => $pullRequests[0]['user'], |
| 124 | + ]; |
| 125 | + } |
116 | 126 | $parenthesis = 'https://github.com/phpstan/phpstan-src/commit/' . $commit['hash']; |
117 | 127 | $thanks = null; |
118 | 128 | $issuesToReference = []; |
|
0 commit comments