From 4abe136db5955de9dd263821f8db65d5b3e0db25 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 1 Feb 2012 18:30:24 +0100 Subject: [PATCH] API CHANGE silverstripe_version file now contains the plain version number, rather than an SVN path --- code/LeftAndMain.php | 27 +++++++-------------------- silverstripe_version | 1 - tests/LeftAndMainTest.php | 19 ------------------- 3 files changed, 7 insertions(+), 40 deletions(-) diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index 8e050593..c9c498eb 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -1109,34 +1109,21 @@ JS; /** * Return the version number of this application. * Uses the subversion path information in /silverstripe_version - * (automacially replaced $URL$ placeholder). + * (automacially replaced by build scripts). * * @return string */ public function CMSVersion() { - $sapphireVersionFile = file_get_contents(BASE_PATH . '/sapphire/silverstripe_version'); - $cmsVersionFile = file_get_contents(BASE_PATH . '/cms/silverstripe_version'); - - $sapphireVersion = $this->versionFromVersionFile($sapphireVersionFile); - $cmsVersion = $this->versionFromVersionFile($cmsVersionFile); + $cmsVersion = file_get_contents(BASE_PATH . '/cms/silverstripe_version'); + $sapphireVersion = file_get_contents(BASE_PATH . '/sapphire/silverstripe_version'); + if(!$cmsVersion || !$sapphireVersion) return; - if($sapphireVersion == $cmsVersion) { + if($cmsVersion == $sapphireVersion) { return $sapphireVersion; - } else { - 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 sprintf("cms: %s, sapphire: %s", $cmsVersion, $sapphireVersion); } + } /** diff --git a/silverstripe_version b/silverstripe_version index 8c6cfe75..e69de29b 100644 --- a/silverstripe_version +++ b/silverstripe_version @@ -1 +0,0 @@ -$URL$ diff --git a/tests/LeftAndMainTest.php b/tests/LeftAndMainTest.php index 295cba3f..6835f7c1 100644 --- a/tests/LeftAndMainTest.php +++ b/tests/LeftAndMainTest.php @@ -14,25 +14,6 @@ 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 */