rev = `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.)
Add New Comment
Viewing 2 Comments
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Add New Comment
Trackbacks
(Trackback URL)