Easy way to embed svn revision number in page in PHP?

Brent picture Brent · Sep 28, 2008 · Viewed 7.6k times · Source

Notice in the bottom right hand corner of this page it has the SVN revision id? I'm assuming that's dynamic.

I'd love to add that to some of my sites, just as a comment in the source to make sure code pushes are going through.

NOTE: You can also assume that the working directory of the site in question is an svn checkout of the repo in question.

Edit: I'm looking for the global revision number, not the revision number of the file I'm looking at.

Answer

Sören Kuklau picture Sören Kuklau · Sep 28, 2008

You can use the svnversion CLI utility to get a more specific look at the revision, including the highest number. You could then use regular expressions to parse this.

Subversion has no concept of a global revision; rather, you'd have to recursively look through the working copy to find the highest revision number. svnversion does that for you.