Skip to content

Commit

Permalink
feat: adjust dashboard output to include issue/PR count (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond authored Oct 4, 2024
1 parent 9261730 commit 0ec7ea0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/Command/DashboardCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -71,7 +70,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
'Repository',
'Latest Release',
'Status',
'Changelog?',
'Issues',
'PRs',
new TableCell('<info>CI?</info>', [
'style' => new TableCellStyle(['align' => 'center']),
]),
Expand All @@ -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), [
Expand Down Expand Up @@ -131,17 +134,6 @@ private static function formatLatest(?Release $release): string
return "<info>{$release->tagName()}</info>";
}

private static function formatChangelog(Repository $repository): string
{
try {
$file = $repository->getFile('CHANGELOG.md');

return \str_contains($file->content(), "[{$repository->releases()->latest()}]") ? '<info>✔</info>' : '<comment>!</comment>';
} catch (ClientExceptionInterface $e) {
return '<fg=red>✖</>';
}
}

private static function releaseStatus(Repository $repository): string
{
if (!$latest = $repository->releases()->latest()) {
Expand Down
10 changes: 10 additions & 0 deletions src/Github/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
}

0 comments on commit 0ec7ea0

Please sign in to comment.