6

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?

5 Answers 5

8

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.

Sign up to request clarification or add additional context in comments.

4 Comments

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 right - updated the answer accordingly. it still might be what he wants ("display current revision on some web page").
Thanks for answers! But I need to display whole web site revision, not separate file(s).
@abatishchev you might want to clarify your question accordingly.
2

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.

2 Comments

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

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.

Comments

1

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:

1 Comment

this is 645945/how-to-display-svn-revision-on-web-site-dynamically
0

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.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.