Skip to content

Commit c4bdd91

Browse files
committed
bug #5881 SelfUpdateCommand - fix link to UPGRADE docs (keradus)
This PR was merged into the 2.19 branch. Discussion ---------- SelfUpdateCommand - fix link to UPGRADE docs closes #5878 Commits ------- c1c011e SelfUpdateCommand - fix link to UPGRADE docs
2 parents 4d09930 + c1c011e commit c4bdd91

File tree

2 files changed

+39
-33
lines changed

2 files changed

+39
-33
lines changed

src/Console/Command/SelfUpdateCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
137137
&& true !== $input->getOption('force')
138138
) {
139139
$output->writeln(sprintf('<info>A new major version of PHP CS Fixer is available</info> (<comment>%s</comment>)', $latestVersion));
140-
$output->writeln(sprintf('<info>Before upgrading please read</info> https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/%s/UPGRADE.md', $latestVersion));
140+
$output->writeln(sprintf('<info>Before upgrading please read</info> https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/%s/UPGRADE-v%s.md', $latestVersion, $currentMajor + 1));
141141
$output->writeln('<info>If you are ready to upgrade run this command with</info> <comment>-f</comment>');
142142
$output->writeln('<info>Checking for new minor/patch version...</info>');
143143

tests/Console/Command/SelfUpdateCommandTest.php

+38-32
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ protected function doSetUp()
4444

4545
file_put_contents($this->getToolPath(), 'Current PHP CS Fixer.');
4646

47-
file_put_contents("{$this->root->url()}/{$this->getNewMinorVersion()}.phar", 'New minor version of PHP CS Fixer.');
48-
file_put_contents("{$this->root->url()}/{$this->getNewMajorVersion()}.phar", 'New major version of PHP CS Fixer.');
47+
file_put_contents("{$this->root->url()}/{$this->getNewMinorReleaseVersion()}.phar", 'New minor version of PHP CS Fixer.');
48+
file_put_contents("{$this->root->url()}/{$this->getNewMajorReleaseVersion()}.phar", 'New major version of PHP CS Fixer.');
4949
}
5050

5151
protected function doTearDown()
@@ -141,30 +141,31 @@ public function testExecute(
141141
public function provideExecuteCases()
142142
{
143143
$currentVersion = Application::VERSION;
144-
$minor = $this->getNewMinorVersion();
144+
$minorRelease = $this->getNewMinorReleaseVersion();
145+
$majorRelease = $this->getNewMajorReleaseVersion();
145146
$major = $this->getNewMajorVersion();
146147

147148
$currentContents = 'Current PHP CS Fixer.';
148149
$minorContents = 'New minor version of PHP CS Fixer.';
149150
$majorContents = 'New major version of PHP CS Fixer.';
150151

151152
$upToDateDisplay = "\033[32mPHP CS Fixer is already up to date.\033[39m\n";
152-
$newMinorDisplay = "\033[32mPHP CS Fixer updated\033[39m (\033[33m{$currentVersion}\033[39m -> \033[33m{$minor}\033[39m)\n";
153-
$newMajorDisplay = "\033[32mPHP CS Fixer updated\033[39m (\033[33m{$currentVersion}\033[39m -> \033[33m{$major}\033[39m)\n";
153+
$newMinorDisplay = "\033[32mPHP CS Fixer updated\033[39m (\033[33m{$currentVersion}\033[39m -> \033[33m{$minorRelease}\033[39m)\n";
154+
$newMajorDisplay = "\033[32mPHP CS Fixer updated\033[39m (\033[33m{$currentVersion}\033[39m -> \033[33m{$majorRelease}\033[39m)\n";
154155
$majorInfoNoMinorDisplay = <<<OUTPUT
155-
\033[32mA new major version of PHP CS Fixer is available\033[39m (\033[33m{$major}\033[39m)
156-
\033[32mBefore upgrading please read\033[39m https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/{$major}/UPGRADE.md
156+
\033[32mA new major version of PHP CS Fixer is available\033[39m (\033[33m{$majorRelease}\033[39m)
157+
\033[32mBefore upgrading please read\033[39m https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/{$majorRelease}/UPGRADE-v{$major}.md
157158
\033[32mIf you are ready to upgrade run this command with\033[39m \033[33m-f\033[39m
158159
\033[32mChecking for new minor/patch version...\033[39m
159160
\033[32mNo minor update for PHP CS Fixer.\033[39m
160161
161162
OUTPUT;
162163
$majorInfoNewMinorDisplay = <<<OUTPUT
163-
\033[32mA new major version of PHP CS Fixer is available\033[39m (\033[33m{$major}\033[39m)
164-
\033[32mBefore upgrading please read\033[39m https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/{$major}/UPGRADE.md
164+
\033[32mA new major version of PHP CS Fixer is available\033[39m (\033[33m{$majorRelease}\033[39m)
165+
\033[32mBefore upgrading please read\033[39m https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/{$majorRelease}/UPGRADE-v{$major}.md
165166
\033[32mIf you are ready to upgrade run this command with\033[39m \033[33m-f\033[39m
166167
\033[32mChecking for new minor/patch version...\033[39m
167-
\033[32mPHP CS Fixer updated\033[39m (\033[33m{$currentVersion}\033[39m -> \033[33m{$minor}\033[39m)
168+
\033[32mPHP CS Fixer updated\033[39m (\033[33m{$currentVersion}\033[39m -> \033[33m{$minorRelease}\033[39m)
168169
169170
OUTPUT;
170171

@@ -178,28 +179,28 @@ public function provideExecuteCases()
178179
[Application::VERSION, Application::VERSION, ['-f' => true], false, $currentContents, $upToDateDisplay],
179180

180181
// new minor version available
181-
[$minor, $minor, [], true, $minorContents, $newMinorDisplay],
182-
[$minor, $minor, ['--force' => true], true, $minorContents, $newMinorDisplay],
183-
[$minor, $minor, ['-f' => true], true, $minorContents, $newMinorDisplay],
184-
[$minor, $minor, [], false, $minorContents, $newMinorDisplay],
185-
[$minor, $minor, ['--force' => true], false, $minorContents, $newMinorDisplay],
186-
[$minor, $minor, ['-f' => true], false, $minorContents, $newMinorDisplay],
182+
[$minorRelease, $minorRelease, [], true, $minorContents, $newMinorDisplay],
183+
[$minorRelease, $minorRelease, ['--force' => true], true, $minorContents, $newMinorDisplay],
184+
[$minorRelease, $minorRelease, ['-f' => true], true, $minorContents, $newMinorDisplay],
185+
[$minorRelease, $minorRelease, [], false, $minorContents, $newMinorDisplay],
186+
[$minorRelease, $minorRelease, ['--force' => true], false, $minorContents, $newMinorDisplay],
187+
[$minorRelease, $minorRelease, ['-f' => true], false, $minorContents, $newMinorDisplay],
187188

188189
// new major version available
189-
[$major, Application::VERSION, [], true, $currentContents, $majorInfoNoMinorDisplay],
190-
[$major, Application::VERSION, [], false, $currentContents, $majorInfoNoMinorDisplay],
191-
[$major, Application::VERSION, ['--force' => true], true, $majorContents, $newMajorDisplay],
192-
[$major, Application::VERSION, ['-f' => true], false, $majorContents, $newMajorDisplay],
193-
[$major, Application::VERSION, ['--force' => true], true, $majorContents, $newMajorDisplay],
194-
[$major, Application::VERSION, ['-f' => true], false, $majorContents, $newMajorDisplay],
190+
[$majorRelease, Application::VERSION, [], true, $currentContents, $majorInfoNoMinorDisplay],
191+
[$majorRelease, Application::VERSION, [], false, $currentContents, $majorInfoNoMinorDisplay],
192+
[$majorRelease, Application::VERSION, ['--force' => true], true, $majorContents, $newMajorDisplay],
193+
[$majorRelease, Application::VERSION, ['-f' => true], false, $majorContents, $newMajorDisplay],
194+
[$majorRelease, Application::VERSION, ['--force' => true], true, $majorContents, $newMajorDisplay],
195+
[$majorRelease, Application::VERSION, ['-f' => true], false, $majorContents, $newMajorDisplay],
195196

196197
// new minor version and new major version available
197-
[$major, $minor, [], true, $minorContents, $majorInfoNewMinorDisplay],
198-
[$major, $minor, [], false, $minorContents, $majorInfoNewMinorDisplay],
199-
[$major, $minor, ['--force' => true], true, $majorContents, $newMajorDisplay],
200-
[$major, $minor, ['-f' => true], false, $majorContents, $newMajorDisplay],
201-
[$major, $minor, ['--force' => true], true, $majorContents, $newMajorDisplay],
202-
[$major, $minor, ['-f' => true], false, $majorContents, $newMajorDisplay],
198+
[$majorRelease, $minorRelease, [], true, $minorContents, $majorInfoNewMinorDisplay],
199+
[$majorRelease, $minorRelease, [], false, $minorContents, $majorInfoNewMinorDisplay],
200+
[$majorRelease, $minorRelease, ['--force' => true], true, $majorContents, $newMajorDisplay],
201+
[$majorRelease, $minorRelease, ['-f' => true], false, $majorContents, $newMajorDisplay],
202+
[$majorRelease, $minorRelease, ['--force' => true], true, $majorContents, $newMajorDisplay],
203+
[$majorRelease, $minorRelease, ['-f' => true], false, $majorContents, $newMajorDisplay],
203204

204205
// weird/unexpected versions
205206
['v0.1.0', 'v0.1.0', [], true, $currentContents, $upToDateDisplay],
@@ -244,7 +245,7 @@ public function testExecuteWhenNotAbleToGetLatestVersions(
244245
) {
245246
$versionChecker = $this->prophesize(\PhpCsFixer\Console\SelfUpdate\NewVersionCheckerInterface::class);
246247

247-
$newMajorVersion = $this->getNewMajorVersion();
248+
$newMajorVersion = $this->getNewMajorReleaseVersion();
248249
$versionChecker->getLatestVersion()->will(function () use ($latestVersionSuccess, $newMajorVersion) {
249250
if ($latestVersionSuccess) {
250251
return $newMajorVersion;
@@ -253,7 +254,7 @@ public function testExecuteWhenNotAbleToGetLatestVersions(
253254
throw new \RuntimeException('Foo.');
254255
});
255256

256-
$newMinorVersion = $this->getNewMinorVersion();
257+
$newMinorVersion = $this->getNewMinorReleaseVersion();
257258
$versionChecker
258259
->getLatestVersionOfMajor($this->getCurrentMajorVersion())
259260
->will(function () use ($latestMinorVersionSuccess, $newMinorVersion) {
@@ -400,13 +401,18 @@ private function getCurrentMajorVersion()
400401
return (int) preg_replace('/^v?(\d+).*$/', '$1', Application::VERSION);
401402
}
402403

403-
private function getNewMinorVersion()
404+
private function getNewMinorReleaseVersion()
404405
{
405406
return "{$this->getCurrentMajorVersion()}.999.0";
406407
}
407408

408409
private function getNewMajorVersion()
409410
{
410-
return ($this->getCurrentMajorVersion() + 1).'.0.0';
411+
return $this->getCurrentMajorVersion() + 1;
412+
}
413+
414+
private function getNewMajorReleaseVersion()
415+
{
416+
return $this->getNewMajorVersion().'.0.0';
411417
}
412418
}

0 commit comments

Comments
 (0)