views:

981

answers:

5

My web site is a checkouted version of SVN repo. I mean .svn folders are placed on web server. I don't use web publishing.

And I want to display current project revision (whole web site) in footer. How can I do that?

If I were using web publishing, I could determine revision on build/publish and write it as static html.

So how to get revision dynamically? Read .svn files directly? Are there better ways?

I saw other such questions, but answer was using SubWCRev.exe, it isn't unfortunately acceptable.

Edit: Tarn gave interesting idea about SVN hooks on commit. Any other ideas?

A: 

The only thing I can think of is to use the svn CLI binaries and call them from the page. That way you can strip out the rest and grab the revision number. To be honest though, its a somewhat ugly solution.

Splash
What is svn CLI binaries?
abatishchev
SVN binaries = the commands one uses on the command line such as 'svn update' and similar. Type 'svn help' (no quotes) on the command line for a helpful list of commands one can use.
Splash
+2  A: 

You can write hooks for SVN. You could write a hook to update a file with the current build as part of your checkout process. Then you can read, cache and display that build number on your site.

tarn
Thanks for idea! Can you provide some more info about writing SVN hooks?
abatishchev
Phil Haack blogged about writing SVN hooks in .NET using CaptainHook http://haacked.com/archive/2006/07/31/CaptainHookIsOnSourceForge.aspx
tarn
+7  A: 

use keyword substitution. enable substitution for the files you want to display revision information, and put a keyword, like $Revision: 144 $, there.

note that

$Rev$ expands to show the last revision in which the file changed, not the last revision to which it was updated

(see link above). if you want to show the global repository revision number, you better use svnversion.

also, see Related.

ax
I have done this in an app variable, worked out really well.
ccook
This will show the revision in which *that particular file* last changed (N). This is not the same as the revision when the part of the repository containing the web site last changed (M). N <= M.
bendin
I can't believe I didn't know about this thanks for the tip
BC
@bendin right - updated the answer accordingly. it still might be what he wants ("display current revision on some web page").
ax
Thanks for answers! But I need to display whole web site revision, not separate file(s).
abatishchev
@abatishchev you might want to clarify your question accordingly.
ax
+1  A: 

If want to display the latest revision number of your entire/repository or branch, keyword substitution will not help, I think a better solution would be to use a Build Management/Continuous Integration software, like CruiseControl.NET or TeamCity with a good build script.

Duplicate of:

CMS
this *is* 645945/how-to-display-svn-revision-on-web-site-dynamically
ax
+1  A: 

This previous question on SO has some discussion that might be useful to you: Always Commit the same file with SVN.

I've always done it by running a script that would use sed to replace a comment with the current timestamp in my $Rev$ file. That way, the file contents would change and Subversion would commit it. Somewhat manual, but you could write a script to first do that, and then do the actual svn commit command.

yukondude