Reputation: 86
Is there a way to show the SVN version of a file, inside the file?
We use SVN for version control. We primarily code in PHP.
What I am trying to do:
So I would like to show what SVN version # the file is inside the head comment block. So I was curious if there is some set of SVN functions/tags that would do that automatically, without having to remember to update the number everytime you commit.
Or I just thought of this one, is there some kind of string replace tag that you could put into the file, that way when you commit to SVN, SVN would swap out the tag with the specific piece of information?
Thank you.
Upvotes: 1
Views: 193
Reputation: 43823
Yes using the SVN keyword $Revision
- see v1.4 of the SVN book for other keywords and how to configure SVN to do the keyword substitution. The keywords can be placed in a comment block as in the following example:
<?php
/*
$LastChangedDate$
$Revision$
*/
?>
v1.6 of SVN introduced additional keywords which might be used, depending on the version you have installed. The latest SVN version at the time of writing is v1.7
Upvotes: 3
Reputation: 2598
According to the PHP documentation, assuming you've got SVN via PHP enabled, you could run
$status = svn_status(__FILE__);
echo $status['revision'];
in the script, where you want to output the svn-revision. The documentation can be found here: http://www.php.net/manual/en/function.svn-status.php
Upvotes: 0