Repository: FriendsOfPHP/PHP-CS-Fixer (php)

Issue:
UPGRADE.md file missing with broken link for php-cs-fixer self-update
## Bug report

From PHP CS Fixer updated (2.18.2 -> v3.0.2)

```
$ php-cs-fixer self-update
A new major version of PHP CS Fixer is available (v3.0.2)
Before upgrading please read https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v3.0.2/UPGRADE.md
If you are ready to upgrade run this command with -f
Checking for new minor/patch version...

```
The file https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v3.0.2/UPGRADE.md is missing




Pull request description:
SelfUpdateCommand - fix link to UPGRADE docs
closes #5878

Patch:
diff --git a/src/Console/Command/SelfUpdateCommand.php b/src/Console/Command/SelfUpdateCommand.php
index 135a916aa..4021db5f6 100644
--- a/src/Console/Command/SelfUpdateCommand.php
+++ b/src/Console/Command/SelfUpdateCommand.php
@@ -137,7 +137,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
             && true !== $input->getOption('force')
         ) {
             $output->writeln(sprintf('<info>A new major version of PHP CS Fixer is available</info> (<comment>%s</comment>)', $latestVersion));
-            $output->writeln(sprintf('<info>Before upgrading please read</info> https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/%s/UPGRADE.md', $latestVersion));
+            $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));
             $output->writeln('<info>If you are ready to upgrade run this command with</info> <comment>-f</comment>');
             $output->writeln('<info>Checking for new minor/patch version...</info>');
 


Test patch:
diff --git a/tests/Console/Command/SelfUpdateCommandTest.php b/tests/Console/Command/SelfUpdateCommandTest.php
index d147da4f2..2a6760ad8 100644
--- a/tests/Console/Command/SelfUpdateCommandTest.php
+++ b/tests/Console/Command/SelfUpdateCommandTest.php
@@ -44,8 +44,8 @@ protected function doSetUp()
 
         file_put_contents($this->getToolPath(), 'Current PHP CS Fixer.');
 
-        file_put_contents("{$this->root->url()}/{$this->getNewMinorVersion()}.phar", 'New minor version of PHP CS Fixer.');
-        file_put_contents("{$this->root->url()}/{$this->getNewMajorVersion()}.phar", 'New major version of PHP CS Fixer.');
+        file_put_contents("{$this->root->url()}/{$this->getNewMinorReleaseVersion()}.phar", 'New minor version of PHP CS Fixer.');
+        file_put_contents("{$this->root->url()}/{$this->getNewMajorReleaseVersion()}.phar", 'New major version of PHP CS Fixer.');
     }
 
     protected function doTearDown()
@@ -141,7 +141,8 @@ public function testExecute(
     public function provideExecuteCases()
     {
         $currentVersion = Application::VERSION;
-        $minor = $this->getNewMinorVersion();
+        $minorRelease = $this->getNewMinorReleaseVersion();
+        $majorRelease = $this->getNewMajorReleaseVersion();
         $major = $this->getNewMajorVersion();
 
         $currentContents = 'Current PHP CS Fixer.';
@@ -149,22 +150,22 @@ public function provideExecuteCases()
         $majorContents = 'New major version of PHP CS Fixer.';
 
         $upToDateDisplay = "\033[32mPHP CS Fixer is already up to date.\033[39m\n";
-        $newMinorDisplay = "\033[32mPHP CS Fixer updated\033[39m (\033[33m{$currentVersion}\033[39m -> \033[33m{$minor}\033[39m)\n";
-        $newMajorDisplay = "\033[32mPHP CS Fixer updated\033[39m (\033[33m{$currentVersion}\033[39m -> \033[33m{$major}\033[39m)\n";
+        $newMinorDisplay = "\033[32mPHP CS Fixer updated\033[39m (\033[33m{$currentVersion}\033[39m -> \033[33m{$minorRelease}\033[39m)\n";
+        $newMajorDisplay = "\033[32mPHP CS Fixer updated\033[39m (\033[33m{$currentVersion}\033[39m -> \033[33m{$majorRelease}\033[39m)\n";
         $majorInfoNoMinorDisplay = <<<OUTPUT
-\033[32mA new major version of PHP CS Fixer is available\033[39m (\033[33m{$major}\033[39m)
-\033[32mBefore upgrading please read\033[39m https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/{$major}/UPGRADE.md
+\033[32mA new major version of PHP CS Fixer is available\033[39m (\033[33m{$majorRelease}\033[39m)
+\033[32mBefore upgrading please read\033[39m https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/{$majorRelease}/UPGRADE-v{$major}.md
 \033[32mIf you are ready to upgrade run this command with\033[39m \033[33m-f\033[39m
 \033[32mChecking for new minor/patch version...\033[39m
 \033[32mNo minor update for PHP CS Fixer.\033[39m
 
 OUTPUT;
         $majorInfoNewMinorDisplay = <<<OUTPUT
-\033[32mA new major version of PHP CS Fixer is available\033[39m (\033[33m{$major}\033[39m)
-\033[32mBefore upgrading please read\033[39m https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/{$major}/UPGRADE.md
+\033[32mA new major version of PHP CS Fixer is available\033[39m (\033[33m{$majorRelease}\033[39m)
+\033[32mBefore upgrading please read\033[39m https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/{$majorRelease}/UPGRADE-v{$major}.md
 \033[32mIf you are ready to upgrade run this command with\033[39m \033[33m-f\033[39m
 \033[32mChecking for new minor/patch version...\033[39m
-\033[32mPHP CS Fixer updated\033[39m (\033[33m{$currentVersion}\033[39m -> \033[33m{$minor}\033[39m)
+\033[32mPHP CS Fixer updated\033[39m (\033[33m{$currentVersion}\033[39m -> \033[33m{$minorRelease}\033[39m)
 
 OUTPUT;
 
@@ -178,28 +179,28 @@ public function provideExecuteCases()
             [Application::VERSION, Application::VERSION, ['-f' => true], false, $currentContents, $upToDateDisplay],
 
             // new minor version available
-            [$minor, $minor, [], true, $minorContents, $newMinorDisplay],
-            [$minor, $minor, ['--force' => true], true, $minorContents, $newMinorDisplay],
-            [$minor, $minor, ['-f' => true], true, $minorContents, $newMinorDisplay],
-            [$minor, $minor, [], false, $minorContents, $newMinorDisplay],
-            [$minor, $minor, ['--force' => true], false, $minorContents, $newMinorDisplay],
-            [$minor, $minor, ['-f' => true], false, $minorContents, $newMinorDisplay],
+            [$minorRelease, $minorRelease, [], true, $minorContents, $newMinorDisplay],
+            [$minorRelease, $minorRelease, ['--force' => true], true, $minorContents, $newMinorDisplay],
+            [$minorRelease, $minorRelease, ['-f' => true], true, $minorContents, $newMinorDisplay],
+            [$minorRelease, $minorRelease, [], false, $minorContents, $newMinorDisplay],
+            [$minorRelease, $minorRelease, ['--force' => true], false, $minorContents, $newMinorDisplay],
+            [$minorRelease, $minorRelease, ['-f' => true], false, $minorContents, $newMinorDisplay],
 
             // new major version available
-            [$major, Application::VERSION, [], true, $currentContents, $majorInfoNoMinorDisplay],
-            [$major, Application::VERSION, [], false, $currentContents, $majorInfoNoMinorDisplay],
-            [$major, Application::VERSION, ['--force' => true], true, $majorContents, $newMajorDisplay],
-            [$major, Application::VERSION, ['-f' => true], false, $majorContents, $newMajorDisplay],
-            [$major, Application::VERSION, ['--force' => true], true, $majorContents, $newMajorDisplay],
-            [$major, Application::VERSION, ['-f' => true], false, $majorContents, $newMajorDisplay],
+            [$majorRelease, Application::VERSION, [], true, $currentContents, $majorInfoNoMinorDisplay],
+            [$majorRelease, Application::VERSION, [], false, $currentContents, $majorInfoNoMinorDisplay],
+            [$majorRelease, Application::VERSION, ['--force' => true], true, $majorContents, $newMajorDisplay],
+            [$majorRelease, Application::VERSION, ['-f' => true], false, $majorContents, $newMajorDisplay],
+            [$majorRelease, Application::VERSION, ['--force' => true], true, $majorContents, $newMajorDisplay],
+            [$majorRelease, Application::VERSION, ['-f' => true], false, $majorContents, $newMajorDisplay],
 
             // new minor version and new major version available
-            [$major, $minor, [], true, $minorContents, $majorInfoNewMinorDisplay],
-            [$major, $minor, [], false, $minorContents, $majorInfoNewMinorDisplay],
-            [$major, $minor, ['--force' => true], true, $majorContents, $newMajorDisplay],
-            [$major, $minor, ['-f' => true], false, $majorContents, $newMajorDisplay],
-            [$major, $minor, ['--force' => true], true, $majorContents, $newMajorDisplay],
-            [$major, $minor, ['-f' => true], false, $majorContents, $newMajorDisplay],
+            [$majorRelease, $minorRelease, [], true, $minorContents, $majorInfoNewMinorDisplay],
+            [$majorRelease, $minorRelease, [], false, $minorContents, $majorInfoNewMinorDisplay],
+            [$majorRelease, $minorRelease, ['--force' => true], true, $majorContents, $newMajorDisplay],
+            [$majorRelease, $minorRelease, ['-f' => true], false, $majorContents, $newMajorDisplay],
+            [$majorRelease, $minorRelease, ['--force' => true], true, $majorContents, $newMajorDisplay],
+            [$majorRelease, $minorRelease, ['-f' => true], false, $majorContents, $newMajorDisplay],
 
             // weird/unexpected versions
             ['v0.1.0', 'v0.1.0', [], true, $currentContents, $upToDateDisplay],
@@ -244,7 +245,7 @@ public function testExecuteWhenNotAbleToGetLatestVersions(
     ) {
         $versionChecker = $this->prophesize(\PhpCsFixer\Console\SelfUpdate\NewVersionCheckerInterface::class);
 
-        $newMajorVersion = $this->getNewMajorVersion();
+        $newMajorVersion = $this->getNewMajorReleaseVersion();
         $versionChecker->getLatestVersion()->will(function () use ($latestVersionSuccess, $newMajorVersion) {
             if ($latestVersionSuccess) {
                 return $newMajorVersion;
@@ -253,7 +254,7 @@ public function testExecuteWhenNotAbleToGetLatestVersions(
             throw new \RuntimeException('Foo.');
         });
 
-        $newMinorVersion = $this->getNewMinorVersion();
+        $newMinorVersion = $this->getNewMinorReleaseVersion();
         $versionChecker
             ->getLatestVersionOfMajor($this->getCurrentMajorVersion())
             ->will(function () use ($latestMinorVersionSuccess, $newMinorVersion) {
@@ -400,13 +401,18 @@ private function getCurrentMajorVersion()
         return (int) preg_replace('/^v?(\d+).*$/', '$1', Application::VERSION);
     }
 
-    private function getNewMinorVersion()
+    private function getNewMinorReleaseVersion()
     {
         return "{$this->getCurrentMajorVersion()}.999.0";
     }
 
     private function getNewMajorVersion()
     {
-        return ($this->getCurrentMajorVersion() + 1).'.0.0';
+        return $this->getCurrentMajorVersion() + 1;
+    }
+
+    private function getNewMajorReleaseVersion()
+    {
+        return $this->getNewMajorVersion().'.0.0';
     }
 }