|
5 | 5 |
|
6 | 6 | require_once __DIR__ . '/vendor/autoload.php'; |
7 | 7 |
|
| 8 | +use Github\Api\GraphQL; |
8 | 9 | use Github\Api\Repo; |
9 | 10 | use Github\Api\Search; |
10 | 11 | use Github\AuthMethod; |
@@ -58,6 +59,9 @@ protected function execute(InputInterface $input, OutputInterface $output) |
58 | 59 | /** @var Repo $repoApi */ |
59 | 60 | $repoApi = $gitHubClient->api('repo'); |
60 | 61 |
|
| 62 | + /** @var GraphQL $graphqlApi */ |
| 63 | + $graphqlApi = $gitHubClient->api('graphql'); |
| 64 | + |
61 | 65 | $command = ['git', 'log', sprintf('%s..%s', $input->getArgument('fromCommit'), $input->getArgument('toCommit'))]; |
62 | 66 | $excludeBranch = $input->getOption('exclude-branch'); |
63 | 67 | if ($excludeBranch !== null) { |
@@ -115,13 +119,42 @@ protected function execute(InputInterface $input, OutputInterface $output) |
115 | 119 |
|
116 | 120 | foreach ($commits as $commit) { |
117 | 121 | $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 | 122 | if (count($pullRequests) > 0) { |
120 | | - $items[] = [ |
121 | | - 'pull_request' => true, |
122 | | - 'number' => $pullRequests[0]['number'], |
123 | | - 'user' => $pullRequests[0]['user'], |
| 123 | + $items = [ |
| 124 | + [ |
| 125 | + 'pull_request' => true, |
| 126 | + 'number' => $pullRequests[0]['number'], |
| 127 | + 'user' => $pullRequests[0]['user'], |
| 128 | + ], |
124 | 129 | ]; |
| 130 | + $autoclosedIssues = $graphqlApi->execute( |
| 131 | + <<<'QUERY' |
| 132 | + query ($owner:String!, $repo:String!, $pr:Int!){ |
| 133 | + repository(owner:$owner, name:$repo){ |
| 134 | + pullRequest(number:$pr){ |
| 135 | + closingIssuesReferences(first:100){ |
| 136 | + nodes { number title url repository { nameWithOwner } } |
| 137 | + } |
| 138 | + } |
| 139 | + } |
| 140 | + }, |
| 141 | + QUERY, |
| 142 | + [ |
| 143 | + 'owner' => 'phpstan', |
| 144 | + 'repo' => 'phpstan-src', |
| 145 | + 'pr' => $pullRequests[0]['number'], |
| 146 | + ], |
| 147 | + ); |
| 148 | + foreach ($autoclosedIssues['data']['repository']['pullRequest']['closingIssuesReferences']['nodes'] as $closedIssue) { |
| 149 | + if ($closedIssue['repository']['nameWithOwner'] !== 'phpstan/phpstan') { |
| 150 | + continue; |
| 151 | + } |
| 152 | + $items[] = [ |
| 153 | + 'number' => $closedIssue['number'], |
| 154 | + ]; |
| 155 | + } |
| 156 | + } else { |
| 157 | + $items = $searchApi->issues(sprintf('repo:phpstan/phpstan %s is:issue', $commit['hash']), 'created')['items']; |
125 | 158 | } |
126 | 159 | $parenthesis = 'https://github.com/phpstan/phpstan-src/commit/' . $commit['hash']; |
127 | 160 | $thanks = null; |
|
0 commit comments