mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
BUGFIX #5073: Fixed CMS version indicator for alpha and beta versions. (from r99789)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@111615 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
4a613c0e02
commit
325a57eea6
@ -1062,23 +1062,24 @@ class LeftAndMain extends Controller {
|
||||
$sapphireVersionFile = file_get_contents(BASE_PATH . '/sapphire/silverstripe_version');
|
||||
$cmsVersionFile = file_get_contents(BASE_PATH . '/cms/silverstripe_version');
|
||||
|
||||
if(strstr($sapphireVersionFile, "/sapphire/trunk")) {
|
||||
$sapphireVersion = "trunk";
|
||||
} else {
|
||||
preg_match("/sapphire\/(?:(?:branches)|(?:tags))(?:\/rc)?\/([A-Za-z0-9._-]+)\/silverstripe_version/", $sapphireVersionFile, $matches);
|
||||
$sapphireVersion = ($matches) ? $matches[1] : null;
|
||||
}
|
||||
|
||||
if(strstr($cmsVersionFile, "/cms/trunk")) {
|
||||
$cmsVersion = "trunk";
|
||||
} else {
|
||||
preg_match("/cms\/(?:(?:branches)|(?:tags))(?:\/rc)?\/([A-Za-z0-9._-]+)\/silverstripe_version/", $cmsVersionFile, $matches);
|
||||
$cmsVersion = ($matches) ? $matches[1] : null;
|
||||
}
|
||||
$sapphireVersion = $this->versionFromVersionFile($sapphireVersionFile);
|
||||
$cmsVersion = $this->versionFromVersionFile($cmsVersionFile);
|
||||
|
||||
return "cms: $cmsVersion, sapphire: $sapphireVersion";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the version from the content of a silverstripe_version file
|
||||
*/
|
||||
public function versionFromVersionFile($fileContent) {
|
||||
if(preg_match('/\/trunk\/silverstripe_version/', $fileContent)) {
|
||||
return "trunk";
|
||||
} else {
|
||||
preg_match("/\/(?:branches|tags\/rc|tags\/beta|tags\/alpha|tags)\/([A-Za-z0-9._-]+)\/silverstripe_version/", $fileContent, $matches);
|
||||
return ($matches) ? $matches[1] : null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
|
@ -14,6 +14,25 @@ class LeftAndMainTest extends FunctionalTest {
|
||||
CMSMenu::populate_menu();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that CMS versions can be interpreted appropriately
|
||||
*/
|
||||
public function testCMSVersion() {
|
||||
$l = new LeftAndMain();
|
||||
$this->assertEquals("2.4", $l->versionFromVersionFile(
|
||||
'$URL: http://svn.silverstripe.com/open/modules/cms/branches/2.4/silverstripe_version $'));
|
||||
$this->assertEquals("2.2.0", $l->versionFromVersionFile(
|
||||
'$URL: http://svn.silverstripe.com/open/modules/cms/tags/2.2.0/silverstripe_version $'));
|
||||
$this->assertEquals("trunk", $l->versionFromVersionFile(
|
||||
'$URL: http://svn.silverstripe.com/open/modules/cms/trunk/silverstripe_version $'));
|
||||
$this->assertEquals("2.4.0-alpha1", $l->versionFromVersionFile(
|
||||
'$URL: http://svn.silverstripe.com/open/modules/cms/tags/alpha/2.4.0-alpha1/silverstripe_version $'));
|
||||
$this->assertEquals("2.4.0-beta1", $l->versionFromVersionFile(
|
||||
'$URL: http://svn.silverstripe.com/open/modules/cms/tags/beta/2.4.0-beta1/silverstripe_version $'));
|
||||
$this->assertEquals("2.4.0-rc1", $l->versionFromVersionFile(
|
||||
'$URL: http://svn.silverstripe.com/open/modules/cms/tags/rc/2.4.0-rc1/silverstripe_version $'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that all subclasses of leftandmain can be accessed
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user