So I started this morning looking to download the latest svn version of osCmax. I am sure the elves have been grinding at the various parts of osCmax providing general users with an improved system for ecommerce.
So I go to http://code.google.com/p/oscmax2/source/checkout and grab the svn command line and use it on my dev linux server to get the latest version.
Start up a fresh site and run the Installer. Which politely informs me that I am using osCMax Power E-Commerce v2.0.25.
WTF? It is 2.5RC2 in the latest download release, why is it still displaying v2.0.25? Hummphhh! I’ve got multiple svn versions and I try to use the code and templates that I develop across the latest public release and more recent svn’s in order to get the best from my sites.
EDIT: The above 2.0.25 was correct because the oscmax2 svn source page gives the latest release version information resulting in that version being downloaded by svn. The more appropriate command line is for a linux testing svn download is
[text]
#svn checkout https://oscmax2.googlecode.com/svn/branches/dev/2.1/ oscmax2-read-only
[/text]
So is there a better way? How about getting the svn version number and publish it alongside the PROJECT_VERSION.
To keep this as a short post this was my way around this:
Create a new file in catalog/includes/svn.php and paste in the following code:
[php]
<?php
/*
$Id: svn.php
osCMax Power E-Commerce
http://howden.net.au/thowden/
Released under the GNU General Public License
*/
// A quick’n’dirty test of publishing to a developer the svn version that is being used
// svn numbering if .svn directory exists then assume that the developer would like to see
// the current version in addition to the PROJECT_VERSION which is consistently out of date
if (!defined(‘REVISION’)) {
if (file_exists(‘.svn/entries’)) {
$svn = file(‘.svn/entries’);
if (is_numeric(trim($svn[3]))) {
$version = $svn[3];
} else { // pre 1.4 svn used xml for this file
$version = explode(‘"’, $svn[4]);
$version = $version[1];
}
define (‘REVISION’, trim($version));
unset ($svn);
unset ($version);
} else {
define (‘REVISION’, 0); // default if no svn data avilable
}
}
?>
[/php]
Save the file and change to edit the install/includes/application.php:
At line 37 which shows
[php]
define(‘PROJECT_VERSION’, ‘osCmax v2.5.0’);
[/php]
and change or insert the following in place of line 37, noting that this is a if else wrap around for the line.
[php highlight=”3″]
require(‘../includes/svn.php’);
if (REVISION == 0) {
define(‘PROJECT_VERSION’, ‘osCmax v2.5.0’);
} else {
define(‘PROJECT_VERSION’, ‘osCmax v2.5.0 svn: ‘.REVISION);
}
[/php]
Then repeat for the main admin application catalog/admin_dir/includes/application_top.php at line 32.
Then repeat again for the main application edit catalog/includes/application_top.php at line 45 except that you removed the ../ from the require() so it is
[php]
require(‘includes/svn.php’);
[/php]
What this does is check for the .svn directory to exist. It will not(should not?) exist in a packaged install like 2.5RC2 but will exist in an svn download. Appending the REVISION to the PROJECT_VERSION constant means that it will appear in all the relevant places in the osCmax site.
Thanks to AD7six at the Bakery for the svn code snippet.
Edit: Thanks to Michael for correcting my understanding of the release version being available from the svn by default and not the latest dev version. However, since writing this post version 2.5 has been released !!
[…] […]
Actually, the source information is NOT outdated. The current stable release is 2.0.25, and so the trunk of the svn repository reflects that. When 2.5.0 released, the trunk will be updated to the 2.5 code base. Until then, the development versions are always in dev branches.
We do not do active development on the trunk code. Only on branches, and then merge back to the trunk on stable releases.
Nice creative solution to the problem you were having.