Skip to content

Commit

Permalink
fix: generate changelog with release when using --from
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond committed Oct 24, 2024
1 parent 8f1dd85 commit e5387f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/Command/ReleaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$io = new SymfonyStyle($input, $output);
$repository = (new Factory())->repository($input->getOption('repository'));
$target = $input->getOption('target') ?? $repository->defaultBranch();
$from = $input->getOption('from') ?? $repository->releases()->on($target)->latest();
$comparison = $repository->compare($target, $from);
$body = [];

if ($comparison->isEmpty()) {
throw new \RuntimeException('No commits.');
}
$from = $input->getOption('from');
$from = $from ? $repository->releases()->get($from) : $repository->releases()->on($target)->latest();

$io->title('Preview Changelog');

Expand Down
11 changes: 11 additions & 0 deletions src/Github/ReleaseCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ public function withoutPreReleases(): self
return $clone;
}

public function get(string $name): ?Release
{
foreach ($this as $release) {
if ($name === $release->name() || $name === $release->tagName()) {
return $release;
}
}

return null;
}

public function latest(): ?Release
{
foreach ($this as $release) {
Expand Down

0 comments on commit e5387f5

Please sign in to comment.