views:

963

answers:

7

Hey,

I'm wondering how do you deal with displaying release revision number when pushing live new versions of your app? You can use $Rev$ in a file to get latest revision, but only after you update the file.

What if I want to update a string in one file every time I change any file in the repository/directory?

Is there a way?

+2  A: 

Did you try to use hooks? They work on server-side only but may do the trick. Otherwise I would just call a script do update the revision if the keywords aren't suitable for you.

unexist
changing code/files in hooks is not recommended
solomongaby
Of course, but it works. If you have a better solution go ahead. ;)
unexist
+1  A: 

Automatically update the file as part of building/deploying the release.

Alexander
How do you automatically update the file as part of the process?
michal kralik
I don't know how your process looks like. You probably have a build tool or scripts where you can add extra steps before creating the package or before copying files into production...
Alexander
+1  A: 

On the one project where I had a reason do this, I cheated: it calls svnversion on itself when it starts up.

Eevee
+7  A: 

The best way to do this is have a build script for releases that will determine the revision number using svnversion or svn info and insert it into a file. It's always helpful to have a script which:

  1. checks out a clean copy of the source into an empty directory
  2. uses svnversion or something similar to compute a build number
  3. compiles source into a product
  4. creates an archive (zip or tarball or whatever) of the product
  5. cleans up: deletes everything but the archive

Then you have a one-step process to create a release with an easily identifiable version. It also helps you avoid giving someone a build from your own working copy, which may have changes that were never checked into source control.

benzado
+1  A: 

As alexander said, one way is to update the revision as part of the build process.

One method of doing this is to take your release builds from an automated build process triggered from your version control checkin, by using a tool such as buildbot.

A scenario might be to trigger the automated build using the post-hook script on your subversion repository. This causes your buildbot to update to the most recently checked in revision. Your build script (eg. Makefile) would use 'svnversion' (or 'svn info' and grep) to read the repository revision and write it into a header file before the build takes place.

After the successful build, automatically check this file back into the repository with a suitable comment about the release version.

Andrew Edgecombe
+3  A: 

There is a simple tool in TortoiseSVN named SubWCRev.exe. It takes revision from path and create file from your own template. You can use it as prebuild command.

DiGi
A: 

unexist made the point, hooks will do the job if configured properly, svnversion has few drawbacks.

Thank you

michal kralik