3

I'd like to update the (highest) revision number to a file inside a subversion repository after each commit.

I thought of a svn version keyword, but doesn't this only get updated if the specific file was changed?

i.e. I have a file version.php where i have the version/revision numbers, but only update anotherfile.php in my commit - this won't change the version/revision information version.php has.

Is a commit hook my only option? If yes, any examples?

Karsten
  • 14,572
  • 5
  • 30
  • 35

4 Answers4

5

Sounds like you want some kind of $GlobalRev$ to get the global revision number into your files.

The appropriate tool you may want to look at would be svnversion

You can use it as post-commit hook or in your build/deployment process to create or modify a global version file.

Also see "Where's $GlobalRev$?" in this page

WiseTechi
  • 3,528
  • 1
  • 22
  • 15
  • 1
    The problem with this approach is that it's a client-side solution. What we really need is a server-side script... – Gili Feb 17 '09 at 21:11
  • Sure, it depends on your deployment process. How do you proceed, some ant task maybe ? – WiseTechi Feb 18 '09 at 09:49
2

We don't do this on commit, we do this as part of our deployment process. The deployment pulls the latest code (or a particular revision) along with the SVN revision number, puts the version in the relvent places (AssemblyInfo, PHP version file etc.) then deploys it to test/UAT/live/whatever.

Steven Robbins
  • 26,441
  • 7
  • 76
  • 90
1

Hook scripts are the only option here. You have two options to accomplish that task: Either verify that the version.php is up-to-date in a pre-commit script, as suggested by the subversion handbook, or initiate another commit updating your version file in a post-commit script. You should not modify the commited files in hooks as pointed out by the handbook.

soulmerge
  • 73,842
  • 19
  • 118
  • 155
0

Subversion uses a repository-wide revision numbering system (see the "Global Revision Numbers" sidebar here), so your file is already being bumped.

Hank Gay
  • 70,339
  • 36
  • 160
  • 222