|
5 | 5 |
|
6 | 6 | require_once __DIR__ . '/vendor/autoload.php'; |
7 | 7 |
|
8 | | -use Github\Api\GraphQL; |
9 | 8 | use Github\Api\PullRequest; |
10 | 9 | use Github\Api\Repo; |
11 | 10 | use Github\Api\Search; |
|
29 | 28 | use function exec; |
30 | 29 | use function explode; |
31 | 30 | use function implode; |
| 31 | +use function preg_match_all; |
32 | 32 | use function preg_replace; |
33 | 33 | use function sprintf; |
34 | 34 |
|
@@ -67,9 +67,6 @@ protected function execute(InputInterface $input, OutputInterface $output) |
67 | 67 | /** @var PullRequest $pullRequestApi */ |
68 | 68 | $pullRequestApi = $gitHubClient->api('pull_request'); |
69 | 69 |
|
70 | | - /** @var GraphQL $graphqlApi */ |
71 | | - $graphqlApi = $gitHubClient->api('graphql'); |
72 | | - |
73 | 70 | $command = ['git', 'log', sprintf('%s..%s', $input->getArgument('fromCommit'), $input->getArgument('toCommit'))]; |
74 | 71 | $excludeBranch = $input->getOption('exclude-branch'); |
75 | 72 | if ($excludeBranch !== null) { |
@@ -135,31 +132,13 @@ protected function execute(InputInterface $input, OutputInterface $output) |
135 | 132 | 'user' => $pullRequests[0]['user'], |
136 | 133 | ], |
137 | 134 | ]; |
138 | | - $autoclosedIssues = $graphqlApi->execute( |
139 | | - <<<'QUERY' |
140 | | - query ($owner:String!, $repo:String!, $pr:Int!){ |
141 | | - repository(owner:$owner, name:$repo){ |
142 | | - pullRequest(number:$pr){ |
143 | | - closingIssuesReferences(first:100){ |
144 | | - nodes { number title url repository { nameWithOwner } } |
145 | | - } |
146 | | - } |
147 | | - } |
148 | | - }, |
149 | | - QUERY, |
150 | | - [ |
151 | | - 'owner' => 'phpstan', |
152 | | - 'repo' => 'phpstan-src', |
153 | | - 'pr' => $pullRequests[0]['number'], |
154 | | - ], |
155 | | - ); |
156 | | - foreach ($autoclosedIssues['data']['repository']['pullRequest']['closingIssuesReferences']['nodes'] as $closedIssue) { |
157 | | - if ($closedIssue['repository']['nameWithOwner'] !== 'phpstan/phpstan') { |
158 | | - continue; |
| 135 | + $prBody = $pullRequests[0]['body'] ?? ''; |
| 136 | + if (preg_match_all('/(?:closes?|fix(?:es)?)\s+(?:https:\/\/github\.com\/phpstan\/phpstan\/issues\/|phpstan\/phpstan#)(\d+)/i', $prBody, $matches)) { |
| 137 | + foreach (array_unique($matches[1]) as $issueNumber) { |
| 138 | + $items[] = [ |
| 139 | + 'number' => (int) $issueNumber, |
| 140 | + ]; |
159 | 141 | } |
160 | | - $items[] = [ |
161 | | - 'number' => $closedIssue['number'], |
162 | | - ]; |
163 | 142 | } |
164 | 143 | } else { |
165 | 144 | $items = $searchApi->issues(sprintf('repo:phpstan/phpstan %s is:issue', $commit['hash']), 'created')['items']; |
|
0 commit comments