diff --git a/src/Command/DashboardCommand.php b/src/Command/DashboardCommand.php index ac7ea99..f763e54 100644 --- a/src/Command/DashboardCommand.php +++ b/src/Command/DashboardCommand.php @@ -19,7 +19,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; use Zenstruck\Changelog\Configuration; use Zenstruck\Changelog\Factory; use Zenstruck\Changelog\Github\Release; @@ -71,7 +70,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'Repository', 'Latest Release', 'Status', - 'Changelog?', + 'Issues', + 'PRs', new TableCell('CI?', [ 'style' => new TableCellStyle(['align' => 'center']), ]), @@ -93,7 +93,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int (string) $repository, self::formatLatest($repository->releases()->latest()), self::releaseStatus($repository), - new TableCell(self::formatChangelog($repository), [ + new TableCell($repository->openIssues(), [ + 'style' => new TableCellStyle(['align' => 'center']), + ]), + new TableCell($repository->openPullRequests(), [ 'style' => new TableCellStyle(['align' => 'center']), ]), new TableCell(self::formatCI($repository), [ @@ -131,17 +134,6 @@ private static function formatLatest(?Release $release): string return "{$release->tagName()}"; } - private static function formatChangelog(Repository $repository): string - { - try { - $file = $repository->getFile('CHANGELOG.md'); - - return \str_contains($file->content(), "[{$repository->releases()->latest()}]") ? '' : '!'; - } catch (ClientExceptionInterface $e) { - return '✖'; - } - } - private static function releaseStatus(Repository $repository): string { if (!$latest = $repository->releases()->latest()) { diff --git a/src/Github/Repository.php b/src/Github/Repository.php index 0cf9ce6..33aaa4b 100644 --- a/src/Github/Repository.php +++ b/src/Github/Repository.php @@ -156,4 +156,14 @@ public function api(): Api { return $this->api; } + + public function openIssues(): int + { + return $this->data['open_issues'] ?? 0; + } + + public function openPullRequests(): int + { + return \count($this->api->request('GET', "/repos/{$this}/pulls?state=open&per_page=100")); + } }