Viewed   81 times

I want to have my PHP application labeled with the revision number which it uses, but I don't want to use CruiseControl or update a file and upload it every time. How should I do it?



SVN keywords is not a good solution. As others pointed out adding $Revision$ in a file only affects the specific file, which may not change for a long time.

Remembering to "edit" a file (by adding or removing a blank line) before every commit is pointless. You could as well just type the revision by hand.

One good way to do it (that I know of) is to have an automated deployment process (which is always a good thing) and using the command svnversion. Here is what I do:

Wherever I need the revision I do an include: <?php include 'version.php'; ?>. This "version.php" file only has the revision number. Moreover it is not part of the repository (it set to be ignored). Here is how I create it:

1) On projects where SVN is installed on the server, I also use it for deployment. Getting the latest version to the server I have a script that among other things does the following (it runs on the server):

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

2) On projects where SVN is not installed my deployment script is more complex: it creates the version.php file locally, zips the code, uploads and extracts it

Tuesday, September 27, 2022

You can use the svnversion CLI utility to get a more specific look at the revision, including the highest number. You could then use regular expressions to parse this.

Subversion has no concept of a global revision; rather, you'd have to recursively look through the working copy to find the highest revision number. svnversion does that for you.

Tuesday, August 2, 2022
// first : get all data, if the data same / duplicate take only one data

$unique = array_unique($data, SORT_REGULAR);

// then, get the data which duplicate with

$diffCellUniq = array_diff_key($data, $unique);

// so print the result

print_r($diffCellUniq); exit;

    [2] => Array
            [a] => 1
            [b] => 2
            [c] => 3
            [d] => 4

Tuesday, December 27, 2022

I'm not sure about the Python specifics, but if put the string $Revision$ into your file somewhere and you have enable-auto-props=true in your SVN config, it'll get rewritten to something like $Revision: 144$. You could then parse this in your script.

There are a number of property keywords you can use in this way.

This won't have any overhead, e.g. querying the SVN repo, because the string is hard-coded into your file on commit or update.

I'm not sure how you'd parse this in Python but in PHP I'd do:

$revString = '$Revision: 144$';
if(preg_match('/: ([0-9]+)$/', $revString, $matches) {
    echo 'Revision is ' . $matches[1];
Sunday, October 2, 2022

You need to compile your jar with debug information. Specifically, you need to find the javac task that compiles the classes that you later jar and add a debug="on" attribute. Example:

<javac srcdir="${src}"
     source="1.4" />

Full details can be found here.

Monday, September 26, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :