Skip to content

Commit 3206a5d

Browse files
committed
Add --no-changelog option to recipes:update
1 parent 2929328 commit 3206a5d

2 files changed

Lines changed: 42 additions & 12 deletions

File tree

src/Command/UpdateRecipesCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Console\Exception\RuntimeException;
2020
use Symfony\Component\Console\Input\InputArgument;
2121
use Symfony\Component\Console\Input\InputInterface;
22+
use Symfony\Component\Console\Input\InputOption;
2223
use Symfony\Component\Console\Output\OutputInterface;
2324
use Symfony\Flex\Configurator;
2425
use Symfony\Flex\Downloader;
@@ -57,6 +58,7 @@ protected function configure(): void
5758
->setAliases(['recipes:update'])
5859
->setDescription('Updates an already-installed recipe to the latest version.')
5960
->addArgument('package', InputArgument::OPTIONAL, 'Recipe that should be updated.')
61+
->addOption('no-changelog', null, InputOption::VALUE_NONE, 'Do not generate the changelog after updating the recipe.')
6062
;
6163
}
6264

@@ -247,7 +249,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
247249
}
248250
}
249251

250-
if ($patch->getPatch()) {
252+
if ($patch->getPatch() && !$input->getOption('no-changelog')) {
251253
$io->write('');
252254
$io->write(' Calculating CHANGELOG...', false);
253255
$changelog = $this->generateChangelog($originalRecipe);

tests/Command/UpdateRecipesCommandTest.php

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,45 @@ protected function tearDown(): void
5858
*
5959
* @requires PHP >= 7.2
6060
*/
61-
public function testCommandUpdatesRecipe()
61+
public function testCommandUpdatesRecipe(): void
62+
{
63+
$this->prepareRecipeUpdateFixture();
64+
65+
$command = $this->createCommandUpdateRecipes();
66+
$command->execute(['package' => 'symfony/console']);
67+
68+
$this->assertSame(0, $command->getStatusCode());
69+
$this->assertStringContainsString('Recipe updated', $this->io->getOutput());
70+
// assert bin/console has changed
71+
$this->assertStringNotContainsString('vendor/autoload.php', file_get_contents(FLEX_TEST_DIR.'/bin/console'));
72+
// assert the recipe was updated
73+
$this->assertStringNotContainsString('c6d02bdfba9da13c22157520e32a602dbee8a75c', file_get_contents(FLEX_TEST_DIR.'/symfony.lock'));
74+
}
75+
76+
/**
77+
* @requires PHP >= 7.2
78+
*/
79+
public function testCommandUpdatesRecipeWithNoChangelog(): void
80+
{
81+
$this->prepareRecipeUpdateFixture();
82+
83+
$command = $this->createCommandUpdateRecipes();
84+
$command->execute([
85+
'package' => 'symfony/console',
86+
'--no-changelog' => true,
87+
]);
88+
89+
$this->assertSame(0, $command->getStatusCode());
90+
$this->assertStringContainsString('Recipe updated', $this->io->getOutput());
91+
$this->assertStringNotContainsString('Calculating CHANGELOG', $this->io->getOutput());
92+
$this->assertStringNotContainsString('No CHANGELOG could be calculated.', $this->io->getOutput());
93+
// assert bin/console has changed
94+
$this->assertStringNotContainsString('vendor/autoload.php', file_get_contents(FLEX_TEST_DIR.'/bin/console'));
95+
// assert the recipe was updated
96+
$this->assertStringNotContainsString('c6d02bdfba9da13c22157520e32a602dbee8a75c', file_get_contents(FLEX_TEST_DIR.'/symfony.lock'));
97+
}
98+
99+
private function prepareRecipeUpdateFixture(): void
62100
{
63101
@mkdir(FLEX_TEST_DIR);
64102
(new Process(['git', 'init'], FLEX_TEST_DIR))->mustRun();
@@ -76,16 +114,6 @@ public function testCommandUpdatesRecipe()
76114
(new Process(['git', 'commit', '-m', 'setup of original console files'], FLEX_TEST_DIR))->mustRun();
77115

78116
(new Process([__DIR__.'/../../vendor/bin/composer', 'install'], FLEX_TEST_DIR))->mustRun();
79-
80-
$command = $this->createCommandUpdateRecipes();
81-
$command->execute(['package' => 'symfony/console']);
82-
83-
$this->assertSame(0, $command->getStatusCode());
84-
$this->assertStringContainsString('Recipe updated', $this->io->getOutput());
85-
// assert bin/console has changed
86-
$this->assertStringNotContainsString('vendor/autoload.php', file_get_contents(FLEX_TEST_DIR.'/bin/console'));
87-
// assert the recipe was updated
88-
$this->assertStringNotContainsString('c6d02bdfba9da13c22157520e32a602dbee8a75c', file_get_contents(FLEX_TEST_DIR.'/symfony.lock'));
89117
}
90118

91119
private function createCommandUpdateRecipes(): CommandTester

0 commit comments

Comments
 (0)