Skip to content

Commit

Permalink
fixup! next
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Jan 2, 2024
1 parent 62919de commit 93a23d1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
21 changes: 8 additions & 13 deletions bin/rng.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,22 @@

declare(strict_types=1);

use Rector\ReleaseNotesGenerator\Changelog\ChangelogContentsFactory;
use Rector\ReleaseNotesGenerator\Command\GenerateCommand;
use Rector\ReleaseNotesGenerator\GithubApiCaller;
use Rector\ReleaseNotesGenerator\GitResolver;
use Symfony\Component\Console\Application;

require __DIR__ . '/../vendor/autoload.php';

$githubToken = getenv('GITHUB_TOKEN');
$githubApiCaller = new GithubApiCaller($githubToken);
$container = new \Illuminate\Container\Container();
$container->when(GithubApiCaller::class)
->needs('$githubToken')
->give(getenv('GITHUB_TOKEN'));

$container = new Illuminate\Container\Container();
$generateChangelogCommand = $container->make(GenerateCommand::class);

$generateChangelogCommand = new GenerateCommand(
new GitResolver(),
$githubApiCaller,
new ChangelogContentsFactory()
);
$generateChangelogCommand = $container->make(GenerateCommand::class);

$application = new Application();
$application->add($generateChangelogCommand);
$application->setDefaultCommand('generate-changelog', true);
$application->run();
$application->setDefaultCommand('generate', true);

exit($application->run());
10 changes: 7 additions & 3 deletions src/Command/GenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Webmozart\Assert\Assert;

final class GenerateCommand extends Command
{
Expand All @@ -39,15 +40,18 @@ public function __construct(

protected function configure(): void
{
$this->setName('generate-changelog');
$this->setName('generate');
$this->addOption(Option::FROM_COMMIT, null, InputOption::VALUE_REQUIRED);
$this->addOption(Option::TO_COMMIT, null, InputOption::VALUE_REQUIRED);
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$fromCommit = (string) $input->getArgument(Option::FROM_COMMIT);
$toCommit = (string) $input->getArgument(Option::TO_COMMIT);
$fromCommit = (string) $input->getOption(Option::FROM_COMMIT);
Assert::notEmpty($fromCommit);

$toCommit = (string) $input->getOption(Option::TO_COMMIT);
Assert::notEmpty($toCommit);

$commits = $this->gitResolver->resolveCommitLinesFromToHashes($fromCommit, $toCommit);

Expand Down

0 comments on commit 93a23d1

Please sign in to comment.