0

I want to put an auto-incremental build number in my PHP-based web application.

Since I'm not compiling, but I'm using svn for source control, I thought that maybe each checkout could count as a build.

Am I right?

If so, how can I get the current svn revision number of the production server local copy via PHP?

If not, what would you say is the best method to put an auto-incremental build number in a web app?

danielpradilla
  • 827
  • 1
  • 8
  • 15

3 Answers3

2

Not used SVN for a long time, but this should work.

$var = '$Id:$';

SVN replaces $Id:$ on every checkout

Update: Seems, that $Rev:$ is more convenient.

KingCrunch
  • 128,817
  • 21
  • 151
  • 173
0

I think Getting the last revision number in SVN? might answer your question!

Community
  • 1
  • 1
Wesley van Opdorp
  • 14,888
  • 4
  • 41
  • 59
0

I found this How can I get the svn revision number in PHP?

Where somebody says that on the deployment script you can include:

cd /var/www/project
svn update
rm version.php
svnversion > version.php

To fill version.php with the current svn version.

Then, you include version.php where you need it.

Also, I found this, that seems to work without updating a specific file:

$path='path_to_your_project';
function get_svn_revision ($path)
{
    $cmd = 'svnversion -n ' . $path;
    $result = (int)exec ($cmd);
    return $result;
}

But since I didn't want to execute a command, I ended up querying /.svn/entries at the root of the project using:

$path='path_to_your_project';
function get_svn_revision($path) {
    $svn = File($path . '/.svn/entries');
    //Revision number is the fourth line
    $result = $svn[3];
    unset($svn);
    return $result;
}
Community
  • 1
  • 1
danielpradilla
  • 827
  • 1
  • 8
  • 15