[TASK] Render only latest three major versions in documentation changelog 49/61449/4
authorFrank Naegler <frank.naegler@typo3.org>
Tue, 6 Aug 2019 21:45:27 +0000 (23:45 +0200)
committerSusanne Moog <look@susi.dev>
Wed, 7 Aug 2019 18:57:08 +0000 (20:57 +0200)
The documentation changelog now renders only the docs for the latest
three major versions.

Resolves: #88884
Releases: master
Change-Id: I43ea7d525cbcf32acc6999b75f08669706051282
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61449
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Susanne Moog <look@susi.dev>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Susanne Moog <look@susi.dev>
typo3/sysext/install/Classes/UpgradeAnalysis/DocumentationFile.php
typo3/sysext/install/Tests/Unit/UpgradeAnalysis/DocumentationFileTest.php

index 9c822c6..7f10db1 100644 (file)
@@ -22,6 +22,7 @@ use TYPO3\CMS\Core\Registry;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
+use TYPO3\CMS\Core\Utility\VersionNumberUtility;
 
 /**
  * Provide information about documentation files
@@ -75,10 +76,14 @@ class DocumentationFile
             throw new \InvalidArgumentException('the given path does not belong to the changelog dir. Aborting', 1537158043);
         }
 
+        $currentVersion = (int)explode('.', VersionNumberUtility::getNumericTypo3Version())[0];
+        $versions = range($currentVersion, $currentVersion - 2);
+        $pattern = '(master|' . implode('\.*|', $versions) . '\.*)';
         $finder = new Finder();
         $finder
             ->depth(0)
             ->sortByName(true)
+            ->name($pattern)
             ->in($path);
 
         $directories = [];
index dc885a1..e80971a 100644 (file)
@@ -20,6 +20,7 @@ use org\bovigo\vfs\vfsStream;
 use org\bovigo\vfs\vfsStreamDirectory;
 use Prophecy\Argument;
 use TYPO3\CMS\Core\Registry;
+use TYPO3\CMS\Core\Utility\VersionNumberUtility;
 use TYPO3\CMS\Install\UpgradeAnalysis\DocumentationFile;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
@@ -78,6 +79,7 @@ class DocumentationFileTest extends UnitTestCase
             'Some more content'
         ];
 
+        $currentVersion = (int)explode('.', VersionNumberUtility::getNumericTypo3Version())[0];
         $structure = [
             'Changelog' => [
                 '1.2' => [
@@ -88,6 +90,18 @@ class DocumentationFileTest extends UnitTestCase
                 '2.0' => [
                     'Important-98574-Issue.rst' => implode("\n", $content_98574),
                 ],
+                $currentVersion-3 . '.0' => [
+                    'Important-98574-Issue.rst' => implode("\n", $content_98574),
+                ],
+                $currentVersion-2 . '.0' => [
+                    'Important-98574-Issue.rst' => implode("\n", $content_98574),
+                ],
+                $currentVersion-1 . '.0' => [
+                    'Important-98574-Issue.rst' => implode("\n", $content_98574),
+                ],
+                $currentVersion . '.0' => [
+                    'Important-98574-Issue.rst' => implode("\n", $content_98574),
+                ],
                 'master' => [
                     'Breaking-13579-Issue.rst' => implode("\n", $content_13579),
                     'Important-13579-Issue.rst' => implode("\n", $content_13579),
@@ -139,11 +153,13 @@ class DocumentationFileTest extends UnitTestCase
     /**
      * @test
      */
-    public function findDocumentationFilesReturnsArrayOfFiles()
+    public function findDocumentationFilesReturnsArrayOfFilesForTheLastThreeMajorVersions()
     {
+        $currentVersion = (int)explode('.', VersionNumberUtility::getNumericTypo3Version())[0];
         $expected = [
-            '1.2' => [],
-            '2.0' => [],
+            $currentVersion-2 . '.0' => [],
+            $currentVersion-1 . '.0' => [],
+            $currentVersion . '.0' => [],
             'master' => [],
         ];