Getting the SVN revision number in Ruby
Friday, July 28th, 2006rev = `svn info`.match('Revision: (\d+)')[1]
That bit of Ruby code will return the Subversion revision number of the working copy it is run in.
`svn info` returns
Path: .
URL: http://svn.yourdomain.com/trunk/Repository UUID: 4e38b711-8f0e-1410-9e15-e3a330ac0d60
Revision: 894
Node Kind: directory
Schedule: normal
Last Changed Author: pwatson
Last Changed Rev: 894
Last Changed Date: 2006-07-28 14:48:28 +0100 (Fri, 28 Jul 2006)
Properties Last Updated: 2006-07-28 14:50:11 +0100 (Fri, 28 Jul 2006)
The regex bit (.match(’Revision: (\d+)’)[1]) then returns the 894 number from that string.
(Thanks to Dela for the regex.)