Skip to content

Commit

Permalink
fix: only look at workflow runs for default branch
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond committed Oct 28, 2024
1 parent 12f883b commit adb2135
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Command/DashboardCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,17 @@ private static function formatCI(Repository $repository): string
return '<comment>(disabled)</comment>';
}

if (!$latestRun = $repository->workflowRuns()[0] ?? []) {
$latestRun = null;

foreach ($repository->workflowRuns() as $run) {
if ($repository->defaultBranch() === $run['head_branch'] && $repository->fullName() === $run['head_repository']['full_name']) {
$latestRun = $run;

break;
}
}

if (!$latestRun) {
return '<comment>(none)</comment>';
}

Expand Down
5 changes: 5 additions & 0 deletions src/Github/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ public function owner(): string
return $this->data['owner']['login'];
}

public function fullName(): string
{
return $this->data['full_name'];
}

public function compare(string $to, ?string $from = null): Comparison
{
return new Comparison($this, $to, $from);
Expand Down

0 comments on commit adb2135

Please sign in to comment.